Skip to content

Instantly share code, notes, and snippets.

@therealplato
Created August 26, 2013 21:07
Show Gist options
  • Save therealplato/6346674 to your computer and use it in GitHub Desktop.
Save therealplato/6346674 to your computer and use it in GitHub Desktop.
// custom error handler
app.use(function (err, req, res, next) {
if (err.message
&& (~err.message.indexOf('not found')
|| (~err.message.indexOf('Cast to ObjectId failed')))) {
return next()
}
console.error(err.stack)
res.status(500).render('500')
})
app.use(function (req, res, next) {
res.status(404).render('404', { url: req.originalUrl })
})
@therealplato
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment