endgame icon indicating copy to clipboard operation
endgame copied to clipboard

Support Non-Standard Errors

Open xjamundx opened this issue 8 years ago • 0 comments

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()))
    }

xjamundx avatar Jul 29 '16 17:07 xjamundx