From 9632e813a550f6e8d75fa535f254e003cbdb9ab5 Mon Sep 17 00:00:00 2001 From: Andrew Hayward Date: Wed, 22 May 2013 10:58:49 -0400 Subject: [PATCH] Fixing #264 --- lib/errors.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/errors.js b/lib/errors.js index c3bc64d..381c75e 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -1,3 +1,5 @@ +var _ = require('underscore'); + function middleware (env, config) { return function(err, req, res, next) { if (req.xhr) @@ -23,8 +25,10 @@ function middleware (env, config) { try { template = env.getTemplate(template); - res.status(err.status); - res.send(template.render({error: err})); + res.status(err.code); + res.send(template.render(_.defaults({ + error: err + }, res.locals))); } catch (e) { if (e.name === 'Template render error') console.log('Error rendering template:', template.path); @@ -73,6 +77,9 @@ function createExceptionType (name, code) { return '[' + this.name + ' Exception: ' + this.message + ']'; } + Exception.status = status; + Exception.code = code; + register[code] = Exception; return Exception;