Add emailing on server exceptions

Keymetrics VC's are coming. They no longer let you see reported
errors or notify you on their free tier which renders the service
useless for us.

This will emailing you using mandrill with a stack trace and
context of the error when it receives it
This commit is contained in:
Berkeley Martinez
2016-01-24 20:05:35 -08:00
parent ea7a695852
commit 169c82acfc
3 changed files with 72 additions and 2 deletions

View File

@@ -4,5 +4,17 @@ export default function keymetrics() {
if (process.env.NODE_ENV !== 'production') {
return (err, req, res, next) => next(err);
}
return pmx.expressErrorHandler();
return (err, req, res, next) => {
if (res.statusCode < 400) { res.statusCode = 500; }
err.url = req.url;
err.component = req.url;
err.action = req.method;
err.params = req.body;
err.session = req.session;
err.username = req.user ? req.user.username : 'anonymous';
err.userId = req.user ? req.user.id : 'anonymous';
return next(pmx.notify(err));
};
}