dyna-no-exit-on-error
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i dyna-no-exit-on-error

Weekly Downloads

4

Version

1.0.3

License

MIT

Unpacked Size

68 kB

Total Files

87

Last publish

Collaborators

  • dennisat