mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
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:
parent
781c038f2b
commit
bc12ca3939
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user