JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 34
  • Score
    100M100P100Q55459F
  • License MIT

Collection of helpers to deal with errors in Node.js

Package Exports

  • bugsy

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (bugsy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

bugsy

Collection of helpers to deal with errors.

Dealing with errors is a common problem in every kind of project. While a lot of libraries simply focus on their creation, this library is meant to deal whole way through their lifecycle.

Features

  • Inheritance management
  • Error severity support
  • Matching transformations
  • Flow definition

Installation

NPM

$ npm install bugsy

Usage

import * as bugsy from 'bugsy';

const RanAwayError = bugsy.create(
  'RanAwayError',
  'It ran away, again',
  { code: 'ran_away' }
);
const MissedThrowError = bugsy.create(
  'MissedThrowError',
  'Throw totally missed',
  { code: 'missed_throw' }
);

function capture() {
  if (Math.random() > 0.9) {
    throw new MissedThrowError();
  } else {
    throw new RanAwayError({ meta: 'Caterpie' }); 
  }
}

bugsy.transform(() => {
  capture();
}, [
  bugsy.code('missed_throw').drop(),
  bugsy.instanceOf(RanAwayError).transform(err => err.level = bugsy.LEVELS_SYSLOG.EMERGENCY)
]);

Licences

MIT