mirror of
https://github.com/sstent/node.git
synced 2026-01-26 15:12:37 +00:00
19 lines
501 B
CoffeeScript
19 lines
501 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
|
|
res.send if 400 <= status < 600 then status else 500
|