harmony 鸿蒙GlobalObserver
GlobalObserver
The GlobalObserver module defines an exception observer. It can be used as an input parameter in ErrorManager.on(‘globalErrorOccurred’) and ErrorManager.on(‘globalUnhandledRejectionDetected’) to listen for event processing of the current application’s main thread.
NOTE
The initial APIs of this module are supported since API version 16. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Modules to Import
import { errorManager } from '@kit.AbilityKit';
Properties
Atomic service API: This API can be used in atomic services since API version 16.
System capability: SystemCapability.Ability.AbilityRuntime.Core
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
reason | GlobalError | Yes | Object related to the exception event name, message, error stack information, exception thread name, and exception thread type. |
Example
import { errorManager } from '@kit.AbilityKit';
function errorFunc(observer: errorManager.GlobalError) {
console.log("result name :" + observer.name);
console.log("result message :" + observer.message);
console.log("result stack :" + observer.stack);
console.log("result instanceName :" + observer.instanceName);
console.log("result instaceType :" + observer.instanceType);
}
errorManager.off('globalErrorOccurred', errorFunc)
你可能感兴趣的鸿蒙文章
harmony 鸿蒙AbilityAccessControl
harmony 鸿蒙OH_NativeBundle_ApplicationInfo
harmony 鸿蒙OH_NativeBundle_ElementName
0
赞
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦