hyper
hyper copied to clipboard
Handle errors better
Right now if hyper hits an error it just throws exceptions. This leaves the connection in an undefined state, and is fundamentally unusable from then on. We should start handling this better. 'Better' means two things:
- [ ] Errors on a single stream should cause us to send
RST_STREAMframes. Exceptions should still be thrown, but the connection should be OK. - [ ] Errors that affect the whole connection should cause us to send
GOAWAYwith an appropriate error code, and then tear the connection down.
The likely best way to handle this is to wrap affected methods in decorators that catch exceptions. We should provide our own set of exceptions that can carry appropriate HTTP/2.0 failure codes on them. Given such an exception, we can use the appropriate frame and code. Unexpected exceptions will get a generic error code.
Would it be appropriate/preferred to define each error in RFC7540 with a corresponding exception?
@fredthomsen Nope, I don't think so. This model is better, I think.
Ok. I'll take a crack at this. I'll start a pull request once I have something.
https://github.com/Lukasa/hyper/pull/188