diff --git a/docs/api/index.md b/docs/api/index.md index 9bcc42d..0ac6e57 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -79,7 +79,6 @@ app.listen(3000); - `app.env` defaulting to the __NODE_ENV__ or "development" - `app.proxy` when true proxy header fields will be trusted - `app.subdomainOffset` offset of `.subdomains` to ignore [2] - - `app.outputErrors` output err.stack to stderr [false in "test" environment] ## app.listen(...) diff --git a/lib/application.js b/lib/application.js index 00f49e4..1241754 100644 --- a/lib/application.js +++ b/lib/application.js @@ -81,7 +81,6 @@ app.listen = function(){ app.toJSON = function(){ return only(this, [ - 'outputErrors', 'subdomainOffset', 'poweredBy', 'env' @@ -156,8 +155,18 @@ app.createContext = function(req, res){ */ app.onerror = function(err){ - if (!this.outputErrors) return; + 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(); diff --git a/test/application.js b/test/application.js index b13a90d..8fbf9b8 100644 --- a/test/application.js +++ b/test/application.js @@ -53,7 +53,6 @@ describe('app.toJSON()', function(){ var obj = app.toJSON(); obj.should.eql({ - outputErrors: false, subdomainOffset: 2, poweredBy: true, env: 'test'