error-plus
v0.0.1
Published
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.
Downloads
4
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