Created
April 22, 2017 12:50
-
-
Save amandeepmittal/3824e907109310deb0c424256c4ac49c to your computer and use it in GitHub Desktop.
Express Handlers
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
/// error handlers | |
// development error handler | |
// will print stacktrace | |
if (app.get('env') === 'development') { | |
app.use(function(err, req, res, next) { | |
res.send('error', { | |
message: err.message, | |
error: err | |
}); | |
}); } | |
// production error handler | |
// no stacktraces leaked to user | |
app.use(function(err, req, res, next) { | |
res.send('error', { | |
message: err.message, | |
error: {} | |
}); }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment