From c16211c5d6c74ca3553ef1f9c81b6108481e84c6 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Thu, 1 May 2014 17:46:09 -0700 Subject: [PATCH] refactor --- lib/application.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/lib/application.js b/lib/application.js index 1241754..a265a0d 100644 --- a/lib/application.js +++ b/lib/application.js @@ -40,8 +40,6 @@ exports = module.exports = Application; function Application() { if (!(this instanceof Application)) return new Application; this.env = process.env.NODE_ENV || 'development'; - this.on('error', this.onerror); - this.outputErrors = 'test' != this.env; this.subdomainOffset = 2; this.poweredBy = true; this.middleware = []; @@ -116,6 +114,8 @@ app.callback = function(){ var fn = co(gen); var self = this; + if (!this.listeners('error').length) this.on('error', this.onerror); + return function(req, res){ res.statusCode = 404; var ctx = self.createContext(req, res); @@ -155,18 +155,8 @@ app.createContext = function(req, res){ */ app.onerror = function(err){ - if (!err) return; - - // suppress output for custom handling - if (1 != this.listeners('error').length) return; - - // ignore 404s if (404 == err.status) return; - - // ignore in test env if ('test' == this.env) return; - - // output console.error(); console.error(err.stack.replace(/^/gm, ' ')); console.error();