A simple error handler library
npm install --save cauliflower
var cauliflower = require('cauliflower');
cauliflower.on('Error.api.networkUnavailable', function (name, e) {
console.log('Error ' + e.message);
});
And elsewhere
var cauliflower = require('cauliflower');
var error = { message: 'Network is unavaiable' };
cauliflower.throw('Error.api.networkUnavailable', error);
var cauliflower = require('cauliflower');
cauliflower.on(/^Error/, function (name, e) {
console.log('Error ' + e.message);
});
var error = { message: 'Permission denied' };
cauliflower.throw('Error.permission', error);
var cauliflower = require('cauliflower');
var myHandler = {
name: 'myUberHandler',
catch: function (name, e) {
console.log('Error ' + name + ' catched: ' + e);
}
};
cauliflower.addHandler(myHandler);
cauliflower.on(/^Error/, 'myUberHandler');
var error = { message: 'Permission denied' };
cauliflower.throw('Error.permission', error);