endgame
endgame copied to clipboard
Support Non-Standard Errors
Currently the failsafe error handler only support Error
objects:
console.error(new Date().toUTCString(), UNCAUGHT, err.message);
console.error(err.stack);
process.exit(1);
Many libs however will throw a string
or even undefined
(terrible).
Here's how I've worked out how to log this stuff:
console.error(new Date().toUTCString(), 'uncaughtException')
if (err && err.stack) {
console.error(err.stack)
} else if (err) {
console.error('No stack trace found.')
console.error(err)
} else {
console.error('No arguments passed to uncaught exception handler.')
console.error(util.inspect(process.memoryUsage()))
}