nodejitsu/node-http-proxy — pull request #457 by philjackson (2013-09-10 14:27:38+00:00)
Title: Emit middlewareError when on middleware error.

A couple of patches (one updating the README) which allow a user to handle middleware errors in much the same way they might in express. For example, within the middleware calling:

next(new Error("I'm a gonner"));

Now emits `middlewareError` and can be handled later like this:

server.proxy.on('middlewareError', function (err, res, req) {
// handle the error here and call res.end()
});

This change is backwardly compatible and the old behaviour persists if nothing heard the `middlewareError` event.