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.
const dynaNoExitOnError = new DynaNoExitOnError({
onError: error => errors.push(error),
onUncaughtException: (error, origin, errorJson) => console.error(error),
onUncaughtRejection: (error, origin, errorJson) => post('/error-report', errorJson),
});
DynaNoExitOnError starts automatically but also provides some methods to handle it.
Enables it, it is auto enabled on start.
Disables the catch.
Terminates the usage, you can restart it with enable()
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!
Occurred on exceptions.
Occurred on exception in Promises
Occurred on any of the above