Created
December 28, 2018 02:22
-
-
Save jsmuster/ae5f9c65e2c350d455ed7b977ff97838 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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