Skip to content
Myr

Fixed issue preventing error handlers from being defined anywhere. Closes #387

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Now we can define them in configure() callbacks etc

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 95aa957 · Browse files · 1 file+22 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+22 added−3 removed

  • other:+22 added−3 removed

1 file+22 added−3 removed

modified:lib/express/server.js+22 added-3 removed
29 unmodified lines
30 this.settings = {};31 this.redirects = {};32 this.viewHelpers = {};33 this.dynamicViewHelpers = {};34 this.errorHandlers = [];35 connect.Server.call(this, middleware || []);3637 // Default "home" to / 38 this.set('home', '/');
33 unmodified lines
7273sys.inherits(Server, connect.Server);7475/**76 * Stack error handler callbacks, then listen on the given77 * `port` and `host`.78 *79 * @param {Number|String} port80 * @param {String} host81 * @return {Type}82 * @api public83 */8485Server.prototype.listen = function(){86 this.errorHandlers.forEach(function(fn){87 this.use(function(err, req, res, next){88 fn.apply(this, arguments);89 });90 }, this);91 connect.Server.prototype.listen.apply(this, arguments);92};9394/**95 * Proxy `connect.Server#use()` to apply settings to96 * mounted applications.97 *98 * @param {String|Function|Server} route
78 unmodified lines
177};178179/**180 * Assign a custom exception handler callback `fn`.181 * These handlers are always _last_ in the middleware stack.182 *183 * @param {Function} fn184 * @return {Server} for chaining185 * @api public186 */187188Server.prototype.error = function(fn){168 this.use(function(err, req, res, next){169 fn.apply(this, arguments);170 });189 this.errorHandlers.push(fn);190 return this;191};192193/**
86 unmodified lines