exceptions.py 936 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # -*- coding: utf-8 -*-
  2. """
  3. hyperframe/exceptions
  4. ~~~~~~~~~~~~~~~~~~~~~
  5. Defines the exceptions that can be thrown by hyperframe.
  6. """
  7. class UnknownFrameError(ValueError):
  8. """
  9. An frame of unknown type was received.
  10. """
  11. def __init__(self, frame_type, length):
  12. #: The type byte of the unknown frame that was received.
  13. self.frame_type = frame_type
  14. #: The length of the data portion of the unknown frame.
  15. self.length = length
  16. def __str__(self):
  17. return (
  18. "UnknownFrameError: Unknown frame type 0x%X received, "
  19. "length %d bytes" % (self.frame_type, self.length)
  20. )
  21. class InvalidPaddingError(ValueError):
  22. """
  23. A frame with invalid padding was received.
  24. """
  25. pass
  26. class InvalidFrameError(ValueError):
  27. """
  28. Parsing a frame failed because the data was not laid out appropriately.
  29. .. versionadded:: 3.0.2
  30. """
  31. pass