Skip to content

Commit

Permalink
add console logs and format using spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelbeltran committed Apr 24, 2024
1 parent d9344d9 commit f0a4690
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions examples/using-domains/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,37 @@ var appDomain = require('domain').create();
// crashes
appDomain.on('error', function (err) {
try {
// Try send data to Raygun
console.log(`Domain error caught: ${err}`);
// Try send data to Raygun
raygunClient.send(err, {}, function () {
// Exit the process once the error has been sent
// Exit the process once the error has been sent
console.log('Error sent to Raygun, exiting process');
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);
// 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
appDomain.run(function () {
var fs = require('fs');

// Try and read a file that doesn't exist
fs.readFile('badfile.json', 'utf8', function(err, file){
if(err) {
// We could send the error straight to Raygun
// raygunClient.send(err);

// Or we can deal with it in our "Fake Error Handler" below

// This will throw an error as fakeErrorHandler doesn't exist
fakeErrorHandler.DealWith(err);
}
})
var fs = require('fs');

console.log('Running example app');

// Try and read a file that doesn't exist
fs.readFile('badfile.json', 'utf8', function (err, file) {
if (err) {
// We could send the error straight to Raygun
// raygunClient.send(err);

// Or we can deal with it in our "Fake Error Handler" below

// This will throw an error as fakeErrorHandler doesn't exist
fakeErrorHandler.DealWith(err);
}
})
});

0 comments on commit f0a4690

Please sign in to comment.