mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
22 lines
573 B
JavaScript
22 lines
573 B
JavaScript
var derby = require('derby')
|
|
, isProduction = derby.util.isProduction
|
|
|
|
module.exports = function(root) {
|
|
var staticPages = derby.createStatic(root)
|
|
|
|
return function(err, req, res, next) {
|
|
if (err == null) return next()
|
|
|
|
console.log(err.stack ? err.stack : err)
|
|
|
|
// Customize error handling here
|
|
var message = err.message || err.toString()
|
|
, status = parseInt(message)
|
|
if (status === 404) {
|
|
staticPages.render('404', res, {url: req.url}, 404)
|
|
} else {
|
|
res.send( ((status >= 400) && (status < 600)) ? status : 500)
|
|
}
|
|
}
|
|
}
|