0.3.2 • Published 8 years ago
debug.me v0.3.2
Installation
install via npm:
npm install debug.me --save
put to config/autoload.js (compoundjs only);
require('debug.me');
Usage
var debugme = require('debug.me');
// global error hanler
debugme.registerGlobalHandler([customHandler]);
// customHandler - optional function param which called with error,
// if customHandler is not specified process will exist,
// when customHandler is specified, then it is a responsibility of
// customHandler to exit process (see example)
// customHandler called after reporting about error
// custom error reporter
var reportError = debugme.errorReporter();
reportError(new Error('Message'), function() {
console.log('error reported');
});
// error reporter middleware for express/compound
app.use(debugme.middleware([customHandler]));
// customHandler - optional function param which called with `error` and `next`
// if customHandler is not specified next will be called inside handler
// when customHandler is specified, then it is a responsibility of
// customHandler to call `next` with error passed to it as first arguments (see example)
// customHandler called after reporting about error
Config (compound apps)
app.enable('send-errors');
app.enable('skip-global-errors');
// optionally customHandler can be specified for uncaught errors
compound.onUncaughtError = function(err) {
compound.log(err);
process.exit(1);
};
// and for uncaught error
compound.onCaughtError = function(err, next) {
compound.log(err);
next(err);
};