Skip to content

Commit

Permalink
use more descriptive exception message
Browse files Browse the repository at this point in the history
  • Loading branch information
Kriechi committed Sep 2, 2020
1 parent 2674bb1 commit fbfb5f0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/hyperframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,19 @@ def __init__(self, stream_id, flags=()):

if (not self.stream_id and
self.stream_association == _STREAM_ASSOC_HAS_STREAM):
raise InvalidDataError('Stream ID must be non-zero')
raise InvalidDataError(
'Stream ID must be non-zero for {}'.format(
type(self).__name__,
)
)
if (self.stream_id and
self.stream_association == _STREAM_ASSOC_NO_STREAM):
raise InvalidDataError('Stream ID must be zero')
raise InvalidDataError(
'Stream ID must be zero for {} with stream_id: {}'.format(
type(self).__name__,
self.stream_id,
)
)

def __repr__(self):
flags = ", ".join(self.flags) or "None"
Expand Down

0 comments on commit fbfb5f0

Please sign in to comment.