Created
May 19, 2014 15:11
-
-
Save ericsaboia/ec73845e01bc31ac2dc1 to your computer and use it in GitHub Desktop.
Sending emails on uncaughtException
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
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