Skip to content

Commit

Permalink
update domain example to use async send
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelbeltran committed May 2, 2024
1 parent 047e2a5 commit 94714b6
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions examples/using-domains/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ var appDomain = require("domain").create();
// Add the error handler so we can pass errors to Raygun when the domain
// crashes
appDomain.on("error", function (err) {
try {
console.log(`Domain error caught: ${err}`);
// Try send data to Raygun
raygunClient.send(err, {}, function () {
console.log(`Domain error caught: ${err}`);
// Try send data to Raygun
raygunClient
.send(err)
.then((message) => {
// Exit the process once the error has been sent
console.log("Error sent to Raygun, exiting process");
process.exit(1);
})
.catch((error) => {
// If there was an error sending to Raygun, log it out and end the process.
// Could possibly log out to a text file here
console.log(error);
process.exit(1);
});
} catch (e) {
// If there was an error sending to Raygun, log it out and end the process.
// Could possibly log out to a text file here
console.log(e);
process.exit(1);
}
});

// Run the domain
Expand Down

0 comments on commit 94714b6

Please sign in to comment.