Skip to content

Commit

Permalink
Handle unhandled rejections and uncaught exceptions with Exceptionless
Browse files Browse the repository at this point in the history
  • Loading branch information
Codycody31 committed Feb 1, 2024
1 parent cf8329e commit df527a4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,19 @@ gracefulShutdown(app, {
});

// Catch unhandled rejections
process.on("unhandledRejection", (err) => {
process.on("unhandledRejection", async (err) => {
if (config.exceptionless.apiKey && config.exceptionless.serverUrl) {
await Exceptionless.submitException(err);
}

log.error("server", "Unhandled rejection: " + err);
console.error(err);
});
process.on("uncaughtException", (err) => {
process.on("uncaughtException", async (err) => {
if (config.exceptionless.apiKey && config.exceptionless.serverUrl) {
await Exceptionless.submitException(err);
}

log.error("server", "Uncaught exception: " + err);
console.error(err);
});

0 comments on commit df527a4

Please sign in to comment.