Socket
Socket
Sign inDemoInstall

bugsy

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bugsy

Collection of helpers to deal with errors in Node.js


Version published
Maintainers
1
Created
Source

bugsy

NPM version

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

  • Isomorphic module
  • Error severity support
  • Flowtype support

Installation

NPM

$ npm install bugsy

Usage

import * as bugsy from 'bugsy';

const CODE_RAN_AWAY = 'ran_away';
const CODE_THROW_MISSED = 'throw_missed';

const RanAwayError = bugsy.newError(CODE_RAN_AWAY, 'It ran away, again');
const ThrowMissedError = bugsy.newError(CODE_THROW_MISSED, 'Throw totally missed');

function capture() {
  if (Math.random() > 0.9) {
    throw new ThrowMissedError({ severity: bugsy.SYSLOG_WARNING });
  } else {
    throw new RanAwayError();
  }
}

function handler(fn) {
  try {
    fn();
  } catch (err) {
    console.log(bugsy.toString(err));
  }
}

handler(() => {
  try {
    capture();
  } catch (err) {
    switch (true) {
      case err.code === CODE_THROW_MISSED:
        break;
      case err instanceof RanAwayError:
        throw (err.addSeverity(bugsy.SYSLOG_EMERGENCY));
      default:
        throw err;
    }
  }
});

Licences

Bugsy is licensed under the MIT License.

Keywords

FAQs

Package last updated on 23 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc