Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/botocore/vendored/requests/packages/urllib3/exceptions.py: 85%
67 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:51 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:51 +0000
2## Base Exceptions
4class HTTPError(Exception):
5 "Base exception used by this module."
6 pass
8class HTTPWarning(Warning):
9 "Base warning used by this module."
10 pass
14class PoolError(HTTPError):
15 "Base exception for errors caused within a pool."
16 def __init__(self, pool, message):
17 self.pool = pool
18 HTTPError.__init__(self, "%s: %s" % (pool, message))
20 def __reduce__(self):
21 # For pickling purposes.
22 return self.__class__, (None, None)
25class RequestError(PoolError):
26 "Base exception for PoolErrors that have associated URLs."
27 def __init__(self, pool, url, message):
28 self.url = url
29 PoolError.__init__(self, pool, message)
31 def __reduce__(self):
32 # For pickling purposes.
33 return self.__class__, (None, self.url, None)
36class SSLError(HTTPError):
37 "Raised when SSL certificate fails in an HTTPS connection."
38 pass
41class ProxyError(HTTPError):
42 "Raised when the connection to a proxy fails."
43 pass
46class DecodeError(HTTPError):
47 "Raised when automatic decoding based on Content-Type fails."
48 pass
51class ProtocolError(HTTPError):
52 "Raised when something unexpected happens mid-request/response."
53 pass
56#: Renamed to ProtocolError but aliased for backwards compatibility.
57ConnectionError = ProtocolError
60## Leaf Exceptions
62class MaxRetryError(RequestError):
63 """Raised when the maximum number of retries is exceeded.
65 :param pool: The connection pool
66 :type pool: :class:`~urllib3.connectionpool.HTTPConnectionPool`
67 :param string url: The requested Url
68 :param exceptions.Exception reason: The underlying error
70 """
72 def __init__(self, pool, url, reason=None):
73 self.reason = reason
75 message = "Max retries exceeded with url: %s (Caused by %r)" % (
76 url, reason)
78 RequestError.__init__(self, pool, url, message)
81class HostChangedError(RequestError):
82 "Raised when an existing pool gets a request for a foreign host."
84 def __init__(self, pool, url, retries=3):
85 message = "Tried to open a foreign host with url: %s" % url
86 RequestError.__init__(self, pool, url, message)
87 self.retries = retries
90class TimeoutStateError(HTTPError):
91 """ Raised when passing an invalid state to a timeout """
92 pass
95class TimeoutError(HTTPError):
96 """ Raised when a socket timeout error occurs.
98 Catching this error will catch both :exc:`ReadTimeoutErrors
99 <ReadTimeoutError>` and :exc:`ConnectTimeoutErrors <ConnectTimeoutError>`.
100 """
101 pass
104class ReadTimeoutError(TimeoutError, RequestError):
105 "Raised when a socket timeout occurs while receiving data from a server"
106 pass
109# This timeout error does not have a URL attached and needs to inherit from the
110# base HTTPError
111class ConnectTimeoutError(TimeoutError):
112 "Raised when a socket timeout occurs while connecting to a server"
113 pass
116class EmptyPoolError(PoolError):
117 "Raised when a pool runs out of connections and no more are allowed."
118 pass
121class ClosedPoolError(PoolError):
122 "Raised when a request enters a pool after the pool has been closed."
123 pass
126class LocationValueError(ValueError, HTTPError):
127 "Raised when there is something wrong with a given URL input."
128 pass
131class LocationParseError(LocationValueError):
132 "Raised when get_host or similar fails to parse the URL input."
134 def __init__(self, location):
135 message = "Failed to parse: %s" % location
136 HTTPError.__init__(self, message)
138 self.location = location
141class ResponseError(HTTPError):
142 "Used as a container for an error reason supplied in a MaxRetryError."
143 GENERIC_ERROR = 'too many error responses'
144 SPECIFIC_ERROR = 'too many {status_code} error responses'
147class SecurityWarning(HTTPWarning):
148 "Warned when perfoming security reducing actions"
149 pass
152class InsecureRequestWarning(SecurityWarning):
153 "Warned when making an unverified HTTPS request."
154 pass
157class SystemTimeWarning(SecurityWarning):
158 "Warned when system time is suspected to be wrong"
159 pass
162class InsecurePlatformWarning(SecurityWarning):
163 "Warned when certain SSL configuration is not available on a platform."
164 pass
167class ResponseNotChunked(ProtocolError, ValueError):
168 "Response needs to be chunked in order to read it as chunks."
169 pass