Emit middlewareError when on middleware error.

Now it's possible to pass an Error object to next() and have it handled
in a custom way that's suitable to your application.
This commit is contained in:
Phil Jackson 2013-09-10 15:16:06 +01:00 committed by indexzero
parent 781c038f2b
commit bc12ca3939

View File

@ -294,6 +294,10 @@ exports.stack = function stack (middlewares, proxy) {
handle = function (req, res) {
var next = function (err) {
if (err) {
if (! proxy.emit('middlewareError', err, res, req)) {
console.error('Error in middleware(s): %s', err.stack);
}
if (res._headerSent) {
res.destroy();
}
@ -303,7 +307,6 @@ exports.stack = function stack (middlewares, proxy) {
res.end('Internal Server Error');
}
console.error('Error in middleware(s): %s', err.stack);
return;
}