Skip to content

Instantly share code, notes, and snippets.

@amandeepmittal
Created April 22, 2017 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amandeepmittal/3824e907109310deb0c424256c4ac49c to your computer and use it in GitHub Desktop.
Save amandeepmittal/3824e907109310deb0c424256c4ac49c to your computer and use it in GitHub Desktop.
Express Handlers
/// 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