Skip to content

Instantly share code, notes, and snippets.

@jsmuster
Created December 28, 2018 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsmuster/ae5f9c65e2c350d455ed7b977ff97838 to your computer and use it in GitHub Desktop.
Save jsmuster/ae5f9c65e2c350d455ed7b977ff97838 to your computer and use it in GitHub Desktop.
let reporter = function (type, ...rest)
{
// remote reporter logic goes here
};
/* handle an uncaught exception & exit the process */
process.on('uncaughtException', function (err)
{
console.error((new Date).toUTCString() + ' uncaughtException:', err.message);
console.error(err.stack);
reporter("uncaughtException", (new Date).toUTCString(), err.message, err.stack);
process.exit(1);
});
/* handle an unhandled promise rejection */
process.on('unhandledRejection', function (reason, promise)
{
console.error('unhandled rejection:', reason.message || reason);
reporter("uncaughtException", (new Date).toUTCString(), reason.message || reason);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment