Package Exports
- custom-err
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 (custom-err) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
custom-err
Easily create an error object with custom properties attached.
API
Err(message, properties)
Usage
var Err = require('custom-err'),
assert = require('assert');
// the first argument represents the error message
// the second argument represents the custom properties object
var myErr = Err('NotFound', { code: 404 });
assert.equal(myErr.message, 'NotFound');
assert.equal(myErr.code, 404);Why?
Because I found myself often writing code like this:
var err = new Error('Not Found');
err.code = 404;
err.someProperty = true;License
MIT