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