https://github.com/aneldev/dyna-no-exit-on-error
Block node js termination and crab uncaught exceptions and rejected promises.
https://github.com/aneldev/dyna-no-exit-on-error
Last synced: 15 days ago
JSON representation
Block node js termination and crab uncaught exceptions and rejected promises.
- Host: GitHub
- URL: https://github.com/aneldev/dyna-no-exit-on-error
- Owner: aneldev
- License: mit
- Created: 2020-07-08T10:46:40.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-09T07:24:53.000Z (almost 6 years ago)
- Last Synced: 2025-10-14T17:14:56.162Z (8 months ago)
- Language: JavaScript
- Size: 222 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# About DynaNoExiOnError
Catches Javascript Exceptions and Rejected Promises and blocks NodeJs instance termination.
Provides callbacks to consume the errors and also gives JSON friendly version for the error. The latter is useful since the `Error` cannot be stringified.
# Example
```
const dynaNoExitOnError = new DynaNoExitOnError({
onError: error => errors.push(error),
onUncaughtException: (error, origin, errorJson) => console.error(error),
onUncaughtRejection: (error, origin, errorJson) => post('/error-report', errorJson),
});
```
# Methods
DynaNoExitOnError starts automatically but also provides some methods to handle it.
## enable(): void
Enables it, it is auto enabled on start.
## disable(): void
Disables the catch.
## dispose(): void
Terminates the usage, you can restart it with `enable()`
# Events
The events are properties of the configuration object on instantiation _see the example above_.
All are optional, if nothing is defined all exceptions the rejected promised will be swallowed!
## onUncaughtException?: (error: any, origin: string, errorJson: any) => void;
Occurred on exceptions.
## onUncaughtRejection?: (error: any, origin: string, errorJson: any) => void;
Occurred on exception in Promises
## onError?: (error: any, origin: string, errorJson: any) => void;
Occurred on any of the above