Socket
Socket
Sign inDemoInstall

bugsy

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 2.0.0

62

package.json
{
"name": "bugsy",
"version": "1.0.0",
"description": "Collection of helpers to deal with errors in Node.js",
"version": "2.0.0",
"description": "Helper to deal with errors lifecycle in javascript",
"author": "Nicolas Jakob <nicow.jakob@gmail.com>",

@@ -17,4 +17,3 @@ "main": "lib/index.js",

"files": [
"lib/index.js",
"lib/index.js.flow"
"lib"
],

@@ -25,4 +24,12 @@ "keywords": [

"exception",
"code",
"universal",
"isomorphic",
"browser",
"severity",
"syslog",
"handler",
"transform",
"helper",
"catch",
"rethrow",
"backend",

@@ -33,15 +40,19 @@ "api"

"clean": "rimraf lib",
"compile": "babel src -d lib --ignore 'tests/*.js' && flow gen-flow-files --out-dir lib src/index.js",
"lint": "eslint --fix .",
"build": "babel src -d lib --ignore '*.test.js' && flow gen-flow-files --out-dir lib src/index.js",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"flow": "flow check",
"test": "npm run lint && npm run flow && npm run compile && mocha --compilers js:babel-core/register 'src/**/tests/**/*.js'",
"bump-major": "npm version major -m \"Bump to %s\"",
"bump-minor": "npm version minor -m \"Bump to %s\"",
"bump-patch": "npm version patch -m \"Bump to %s\"",
"prepublish": "npm run test"
"test": "ava",
"test:watch": "ava -w",
"check": "npm run lint && npm run flow && npm run test",
"bump:major": "npm version major -m \"Bump to %s\"",
"bump:minor": "npm version minor -m \"Bump to %s\"",
"bump:patch": "npm version patch -m \"Bump to %s\"",
"prepublish": "npm run check"
},
"devDependencies": {
"babel-cli": "^6.16.0",
"babel-core": "^6.17.0",
"babel-eslint": "^6.1.2",
"ava": "^0.17.0",
"babel-cli": "^6.18.0",
"babel-core": "^6.21.0",
"babel-eslint": "^7.1.1",
"babel-plugin-syntax-flow": "^6.13.0",

@@ -52,14 +63,13 @@ "babel-plugin-transform-builtin-extend": "^1.1.0",

"babel-preset-stage-0": "^6.5.0",
"chai": "^3.5.0",
"eslint": "^3.5.0",
"eslint-config-njakob": "^2.1.0",
"eslint-plugin-flowtype": "^2.19.0",
"eslint-plugin-import": "^1.15.0",
"flow-bin": "^0.33.0",
"istanbul": "0.4.4",
"koa": "2.0.0",
"mocha": "2.5.3",
"rimraf": "^2.5.4",
"should": "10.0.0"
"eslint": "^3.12.1",
"eslint-config-njakob": "~3.0.6",
"eslint-plugin-flowtype": "^2.18.2",
"eslint-plugin-import": "^2.2.0",
"flow-bin": "^0.37.4",
"rimraf": "^2.5.4"
},
"ava": {
"require": "babel-register",
"babel": "inherit"
}
}
# bugsy
# bugsy [![NPM version][npm-status-image]][npm] [![Build Status][build-status-image]][travis] [![ESLint Config][eslint-config-image]][eslint-config]
[![NPM version][npm-status-image]][npm]
Helper to deal with errors lifecycle in javascript.
Collection of helpers to deal with errors.
Dealing with errors is a common problem in every small or large project. While a lot of libraries simply focus on their creation, this library is meant to deal with their lifecycle.
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
* Universal module
* Error severity
* Custom metadata
* Flowtype

@@ -23,2 +19,4 @@ ## Installation

With NPM:
```

@@ -28,18 +26,28 @@ $ npm install bugsy

With Yarn:
```
$ yarn add bugsy
```
## Usage
```javascript
```js
import * as bugsy from 'bugsy';
const CODE_RAN_AWAY = 'ran_away';
const CODE_THROW_MISSED = 'throw_missed';
const RAN_AWAY = 'ran_away';
const 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');
const ranAway = bugsy.createError(RAN_AWAY, 'It ran away, again');
const throwMissed = bugsy.createError(THROW_MISSED, 'Throw totally missed');
function capture() {
if (Math.random() > 0.9) {
throw new ThrowMissedError({ severity: bugsy.SYSLOG_WARNING });
const r = Math.random();
if (r < 0.3) {
throw throwMissed({ severity: bugsy.syslog.WARNING });
} else if (r < 0.6) {
throw ranAway();
} else {
throw new RanAwayError();
throw new Error();
}

@@ -60,9 +68,10 @@ }

} catch (err) {
switch (true) {
case err.code === CODE_THROW_MISSED:
switch (err.code) {
case THROW_MISSED:
console.log('Oh well...');
break;
case err instanceof RanAwayError:
throw (err.addSeverity(bugsy.SYSLOG_EMERGENCY));
case RAN_AWAY:
throw err.setSeverity(bugsy.syslog.CRITICAL).addMeta({ firstTry: true });
default:
throw err;
throw bugsy.convert(err).setSeverity(bugsy.syslog.EMERGENCY);
}

@@ -75,7 +84,11 @@ }

Bugsy is licensed under the [MIT License][licence].
`njakob/bugsy` is licensed under the [MIT License][licence].
[licence]: LICENSE
[eslint-config]: https://github.com/njakob/eslint-config
[npm]: https://nodei.co/npm/bugsy/
[travis]: https://travis-ci.org/njakob/bugsy
[npm-install-image]: https://nodei.co/npm/bugsy.png?downloads=true
[npm-status-image]: https://img.shields.io/npm/v/bugsy.svg
[npm-status-image]: https://img.shields.io/npm/v/bugsy.svg
[build-status-image]: https://travis-ci.org/njakob/bugsy.svg?branch=master
[eslint-config-image]: https://img.shields.io/badge/eslint_config-njakob-463fd4.svg
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc