README
eErr
Error Event Handller.
Installation
npm install --save eerr
Usage
example
var eerr = require('eerr');
eerr.setup({
badrequest: { status: 400, message: 'Bad Request.' },
unauthorized: { status: 401, message: 'Unauthorized.' },
forbidden: { status: 403, message: 'Forbidden' },
notfound: { status: 404, message: 'Not Found.' },
internalservererror: { status: 500, message: 'Internal Server Error.' },
gatewaytimeout: { status: 504, message: 'Gateway Timeout.' }
});
// error code event.
eerr.on('badrequest', function(err) {
console.log('bad request!');
});
// error status event.
eerr.on('404', function(err) {
console.log('not found!');
});
// error status event.
eerr.on('4XX', function(err) {
console.log('client error!');
});
var err = eerr('notfound');
console.log(err.name, err.code, err.status, err.message, err.stack);
// -- output
// not found!
// client error!
// Error notfound 404 Not Found ErrorStack...
Contribution
- Fork it ( https://github.com/iyu/eerr/fork )
- Create a feature branch
- Commit your changes
- Rebase your local changes against the master branch
- Run test suite with the
npm test; npm run-script jshint
command and confirm that it passes - Create new Pull Request