Share your code.
endgamepublic
endgame
A tiny module for ensuring uncaught exceptions are handled in Node.js.
Usage
Basic
Simply require
and invoke.
// failed.js var endgame = ; ; throw 'y u no work?'; // Thu, 09 Jan 2014 20:03:18 GMT uncaughtException y u no work? // Error: y u no work? // at Object._onImmediate (/Users/me/src/git/myapp/failed.js:7:0) // at processImmediate [as _immediateCallback] (timers.js:330:15)
Undo
If an uncaughtException
handler has already been registered, endgame
becomes a noop. If an uncaughtException
handler
is registered after endgame
has been invoked, endgame
's default handler is automatically removed in favor of the newly
registered handler.
endgame
also returns a function that can be invoked to undo endgame
's behavior.
// undo.js var endgame = undo = ; // do stuff and decide to revert `endgame` changes ;
Custom handler
// custom.js var endgame undo; endgame = ;undo = ; // ... // implicit endgame undo process; // or `undo();`