@bryandollery/errors-and-signals
v1.0.3
Published
A handler for signals and global errors
Downloads
11
Readme
Description
A simple handler for otherwise unhandled exceptions and signals in node
Usage
Install
npm i @bryandollery/errors-and-signals
Import
import { errors-and-signals } from "@bryandollery/errors-and-signals";
Configure
const ctx = "myappname";
errorsAndSignals(async () => {
await producer.disconnect();
}, ctx);
The first parameter is a handler for freeing resources, the second optional paramemter is a context used for logging. Output logs are json strings mostly at the INFO or ERROR levels.
Notes
The errors and signals handled by this library are defined by:
const errorTypes = ["unhandledRejection", "uncaughtException"];
const signalTraps = ["SIGTERM", "SIGINT", "SIGUSR2"];