Skip to content

Instantly share code, notes, and snippets.

@ericsaboia
Created May 19, 2014 15:11
Show Gist options
  • Save ericsaboia/ec73845e01bc31ac2dc1 to your computer and use it in GitHub Desktop.
Save ericsaboia/ec73845e01bc31ac2dc1 to your computer and use it in GitHub Desktop.
Sending emails on uncaughtException
if (config.admin.email) {
process.on('uncaughtException', function(err) {
console.log(err.stack);
nodemailer.createTransport("SMTP", {
service: "Sendgrid"
, auth: {
user: config.smtp.username
, pass: config.smtp.password
}
}).sendMail({
from: config.smtp.noReply
, to: config.admin.email
, subject: 'Node.js - uncaughtException'
, text: err.stack
}, function(err,response) {
process.exit(1);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment