Skip to content

Commit

Permalink
Improve error message for unexpected events
Browse files Browse the repository at this point in the history
Before:

can't handle event type <class 'h11._events.ConnectionClosed'> for SERVER in state SEND_BODY"

After:

can't handle event type ConnectionClosed when role=SERVER and state=SEND_BODY
  • Loading branch information
njsmith committed Dec 2, 2016
1 parent 185dba8 commit 421d322
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions h11/_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ def _fire_event_triggered_transitions(self, role, event_type):
new_state = EVENT_TRIGGERED_TRANSITIONS[role][state][event_type]
except KeyError:
raise LocalProtocolError(
"can't handle event type {} for {} in state {}"
.format(event_type, role, self.states[role]))
"can't handle event type {} when role={} and state={}"
.format(event_type.__name__, role, self.states[role]))
self.states[role] = new_state

def _fire_state_triggered_transitions(self):
Expand Down

0 comments on commit 421d322

Please sign in to comment.