UNPKG

error-ninja

Version:

A handy library for creating custom error constructors that work across async boundaries in Node.js.

25 lines (20 loc) 657 B
'use strict'; /* * EXAMPLE */ const setupErrorNinja = require(`../src/main`); setupErrorNinja({ stackTraceLimit: 20, fullInsight: true, handleUncaughtExceptions: true, forceInstallExceptionHandlers: true, exitOnUncaughtException: true, }); /* * Example of unhandled errors. * * The REJECTED promise error will be output to the terminal AFTER the THROWN error because it's asynchronous and we * only exit the process during the subsequent iteration of the event loop. */ Promise.reject(new Error(`Whoops, we didn't catch this promise!`)); // eslint-disable-line promise/catch-or-return throw new Error(`Whoops, we didn't catch this error!`);