Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

error-plus

lukebond10MIT0.0.1

Simple extension to standard Node.js Error object that allows you to pass an addition object to the constructor whose keys will be added to the Error object.

error, wrap, wrapper, plus

readme

_error

A simple extension to the Node.js built-in Error object to allow you to pass an object to the constructor whose keys will be put into the Error object.

Usage

Perhaps you currently do this:

var err = new Error('Something bad happened');
err.statusCode = 400;
err.pertinentInformation = 'something';
return callback(err);

Now you can now do this:

var _Error = require('error-plus');
return callback(new _Error('Something bad happened', {statusCode: 400, pertinentInformation: 'something'}));

That's all there is to it.

Tests are included.

Licence

MIT