exceptions.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # -*- coding: utf-8 -*-
  2. """
  3. hyper/common/exceptions
  4. ~~~~~~~~~~~~~~~~~~~~~~~
  5. Contains hyper's exceptions.
  6. """
  7. class ChunkedDecodeError(Exception):
  8. """
  9. An error was encountered while decoding a chunked response.
  10. """
  11. pass
  12. class InvalidResponseError(Exception):
  13. """
  14. A problem was found with the response that makes it invalid.
  15. """
  16. pass
  17. class SocketError(Exception):
  18. """
  19. An error occurred during socket operation.
  20. """
  21. pass
  22. class LineTooLongError(Exception):
  23. """
  24. An attempt to read a line from a socket failed because no newline was
  25. found.
  26. """
  27. pass
  28. # Create our own ConnectionResetError.
  29. try: # pragma: no cover
  30. ConnectionResetError = ConnectionResetError
  31. except NameError: # pragma: no cover
  32. class ConnectionResetError(Exception):
  33. """
  34. A HTTP connection was unexpectedly reset.
  35. """
  36. class TLSUpgrade(Exception):
  37. """
  38. We upgraded to a new protocol in the NPN/ALPN handshake.
  39. """
  40. def __init__(self, negotiated, sock):
  41. super(TLSUpgrade, self).__init__()
  42. self.negotiated = negotiated
  43. self.sock = sock
  44. class HTTPUpgrade(Exception):
  45. """
  46. We upgraded to a new protocol via the HTTP Upgrade response.
  47. """
  48. def __init__(self, negotiated, sock):
  49. super(HTTPUpgrade, self).__init__()
  50. self.negotiated = negotiated
  51. self.sock = sock
  52. class MissingCertFile(Exception):
  53. """
  54. The certificate file could not be found.
  55. """
  56. pass