This commit is contained in:
TJ Holowaychuk 2014-05-01 17:46:09 -07:00
parent 212137139a
commit c16211c5d6

View file

@ -40,8 +40,6 @@ exports = module.exports = Application;
function Application() { function Application() {
if (!(this instanceof Application)) return new Application; if (!(this instanceof Application)) return new Application;
this.env = process.env.NODE_ENV || 'development'; this.env = process.env.NODE_ENV || 'development';
this.on('error', this.onerror);
this.outputErrors = 'test' != this.env;
this.subdomainOffset = 2; this.subdomainOffset = 2;
this.poweredBy = true; this.poweredBy = true;
this.middleware = []; this.middleware = [];
@ -116,6 +114,8 @@ app.callback = function(){
var fn = co(gen); var fn = co(gen);
var self = this; var self = this;
if (!this.listeners('error').length) this.on('error', this.onerror);
return function(req, res){ return function(req, res){
res.statusCode = 404; res.statusCode = 404;
var ctx = self.createContext(req, res); var ctx = self.createContext(req, res);
@ -155,18 +155,8 @@ app.createContext = function(req, res){
*/ */
app.onerror = function(err){ 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; if (404 == err.status) return;
// ignore in test env
if ('test' == this.env) return; if ('test' == this.env) return;
// output
console.error(); console.error();
console.error(err.stack.replace(/^/gm, ' ')); console.error(err.stack.replace(/^/gm, ' '));
console.error(); console.error();