Files
habitica/src/server/serverError.coffee
T
2013-01-20 12:11:21 -05:00

21 lines
570 B
CoffeeScript

derby = require 'derby'
{isProduction} = derby.util
module.exports = (root) ->
staticPages = derby.createStatic root
return (err, req, res, next) ->
return next() unless err?
console.log(if err.stack then err.stack else err)
## Customize error handling here ##
message = err.message || err.toString()
status = parseInt message
if status is 404
staticPages.render '404', res, {url: req.url}, 404
else if status >= 400 and status < 600
res.send status
else
#TODO send error to email
res.redirect('/500.html')