Custom Error class for `util.inherits`
npm install my-errorutil.inherits.
npm install my-error --save
`
Usage
`javascript
var MyError = require('my-error');
// create your custom error
function CodeError(code, message) {
CodeError.super_.call(this, message);
this.code = code;
}
util.inherits(CodeError, MyError);
`
`javascript
// later on..
try {
throw new CodeError(404, 'Not Found!');
} catch (err) {
// do some thing...
// err.name === 'CodeError';
// err.code === 404;
// err.message === 'Not Found!';
// err instanceof CodeError;
// err instanceof Error;
}
``