Skip to content

Commit

Permalink
Add pmx error handler for loggign to keymetrics
Browse files Browse the repository at this point in the history
  • Loading branch information
terakilobyte committed Jun 16, 2015
1 parent 7f311a1 commit 5b74212
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"passport-local": "^1.0.0",
"passport-oauth": "^1.0.0",
"passport-twitter": "^1.0.3",
"pmx": "^0.3.16",
"ramda": "~0.10.0",
"request": "~2.53.0",
"rx": "^2.5.3",
Expand Down
12 changes: 4 additions & 8 deletions server/server.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
require('dotenv').load();
require('pmx').init();
// handle uncaught exceptions. Forever will restart process on shutdown
process.on('uncaughtException', function (err) {
console.error(
(new Date()).toUTCString() + ' uncaughtException:',
err.message
);
console.error(err.stack);
process.exit(1); // eslint-disable-line
});

var R = require('ramda'),
assign = require('lodash').assign,
Expand All @@ -28,6 +21,7 @@ var R = require('ramda'),
expressValidator = require('express-validator'),
forceDomain = require('forcedomain'),
lessMiddleware = require('less-middleware'),
pmx = require('pmx'),

passportProviders = require('./passport-providers'),
/**
Expand Down Expand Up @@ -248,9 +242,11 @@ R.keys(passportProviders).map(function(strategy) {
/**
* 500 Error Handler.
*/

if (process.env.NODE_ENV === 'development') {
app.use(errorHandler({ log: true }));
} else {
app.use(pmx.expressErrorHandler());
// error handling in production disabling eslint due to express parity rules
// for error handlers
app.use(function(err, req, res, next) { // eslint-disable-line
Expand Down

0 comments on commit 5b74212

Please sign in to comment.