npm.io
1.0.3 • Published 4 years ago

@bryandollery/errors-and-signals

Licence
MIT
Version
1.0.3
Deps
0
Size
4 kB
Vulns
0
Weekly
0

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"];

Keywords