refactor: use licia uncaught for catching errors

This commit is contained in:
redhoodsu
2019-10-01 11:11:21 +08:00
parent ea4cad4a04
commit 67fcd71b17
4 changed files with 218 additions and 92 deletions

View File

@@ -2555,6 +2555,41 @@ ucs2.decode('abc'); // -> [0x61, 0x62, 0x63]
ucs2.decode('𝌆').length; // -> 1
```
## uncaught
Handle global uncaught errors and promise rejections.
### start
Start handling of errors.
### stop
Stop handling.
### addListener
Add listener for handling errors.
|Name|Type |Desc |
|----|--------|--------------|
|fn |function|Error listener|
### rmListener
Remove listener.
### rmAllListeners
Remove all listeners.
```javascript
uncaught.start();
uncaught.addListener(err => {
// Do something.
});
```
## uniqId
Generate a globally-unique id.