python-hyper / h11

A pure-Python, bring-your-own-I/O implementation of HTTP/1.1
https://h11.readthedocs.io/
MIT License
490 stars 62 forks source link

Add the current state when raising LocalProtocolError("not in a reusable state") #80

Closed alanbchristie closed 5 years ago

alanbchristie commented 5 years ago

I'm experiencing LocalProtocolError("not in a reusable state")exceptions when using hypercorn (see https://github.com/pgjones/hypercorn/issues/18).

It would be extremely valuable if the current state were logged with the exception that occurs in _state.py's start_next_cycle(self) method. Then the user would know what the state is as well as what it is expected to be.

njsmith commented 5 years ago

That would make that error message more informative, wouldn't it!

Any interest in putting together a PR? The code that raises that exception is at the bottom of h11/_state.py.

alanbchristie commented 5 years ago

Can do - but my 'day job' gets in the way during normal hours. Happy to look at this after 6pm tonight.

alanbchristie commented 5 years ago

Changes tested and present in https://github.com/python-hyper/h11/pull/81