Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Triggering an event on response in case of error occurred #809
I want to discuss a possibility of triggering an event on response in case of error occurred.
Why do I need this for? Some middlewares like connect-pgclient or connect-reqcontext need to provide a cleanup mechanism which handles an error but currently the only way to do this is to introduce another middleware, see the example in connect-reqcontext which implemented as a pair of middlewares.
I think that such API is erroneous — user has not to forget about second middleware and has to decide where to put it. The more robust solution would be to connect to trigger some kind of event on error so middlewre could subscribe to it like
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
Yes, this would be cool. I had a chat with @visionmedia on the #express channel a month or so ago asking if there was a way to know if the request was in error (ie.