]>
jfr.im git - dlqueue.git/blob - venv/lib/python3.11/site-packages/pip/_vendor/requests/exceptions.py
5 This module contains the set of Requests' exceptions.
7 from pip
._vendor
.urllib3
.exceptions
import HTTPError
as BaseHTTPError
9 from .compat
import JSONDecodeError
as CompatJSONDecodeError
12 class RequestException(IOError):
13 """There was an ambiguous exception that occurred while handling your
17 def __init__(self
, *args
, **kwargs
):
18 """Initialize RequestException with `request` and `response` objects."""
19 response
= kwargs
.pop("response", None)
20 self
.response
= response
21 self
.request
= kwargs
.pop("request", None)
22 if response
is not None and not self
.request
and hasattr(response
, "request"):
23 self
.request
= self
.response
.request
24 super().__init
__(*args
, **kwargs
)
27 class InvalidJSONError(RequestException
):
28 """A JSON error occurred."""
31 class JSONDecodeError(InvalidJSONError
, CompatJSONDecodeError
):
32 """Couldn't decode the text into json"""
34 def __init__(self
, *args
, **kwargs
):
36 Construct the JSONDecodeError instance first with all
37 args. Then use it's args to construct the IOError so that
38 the json specific args aren't used as IOError specific args
39 and the error message from JSONDecodeError is preserved.
41 CompatJSONDecodeError
.__init
__(self
, *args
)
42 InvalidJSONError
.__init
__(self
, *self
.args
, **kwargs
)
45 class HTTPError(RequestException
):
46 """An HTTP error occurred."""
49 class ConnectionError(RequestException
):
50 """A Connection error occurred."""
53 class ProxyError(ConnectionError
):
54 """A proxy error occurred."""
57 class SSLError(ConnectionError
):
58 """An SSL error occurred."""
61 class Timeout(RequestException
):
62 """The request timed out.
64 Catching this error will catch both
65 :exc:`~requests.exceptions.ConnectTimeout` and
66 :exc:`~requests.exceptions.ReadTimeout` errors.
70 class ConnectTimeout(ConnectionError
, Timeout
):
71 """The request timed out while trying to connect to the remote server.
73 Requests that produced this error are safe to retry.
77 class ReadTimeout(Timeout
):
78 """The server did not send any data in the allotted amount of time."""
81 class URLRequired(RequestException
):
82 """A valid URL is required to make a request."""
85 class TooManyRedirects(RequestException
):
86 """Too many redirects."""
89 class MissingSchema(RequestException
, ValueError):
90 """The URL scheme (e.g. http or https) is missing."""
93 class InvalidSchema(RequestException
, ValueError):
94 """The URL scheme provided is either invalid or unsupported."""
97 class InvalidURL(RequestException
, ValueError):
98 """The URL provided was somehow invalid."""
101 class InvalidHeader(RequestException
, ValueError):
102 """The header value provided was somehow invalid."""
105 class InvalidProxyURL(InvalidURL
):
106 """The proxy URL provided is invalid."""
109 class ChunkedEncodingError(RequestException
):
110 """The server declared chunked encoding but sent an invalid chunk."""
113 class ContentDecodingError(RequestException
, BaseHTTPError
):
114 """Failed to decode response content."""
117 class StreamConsumedError(RequestException
, TypeError):
118 """The content for this response was already consumed."""
121 class RetryError(RequestException
):
122 """Custom retries logic failed"""
125 class UnrewindableBodyError(RequestException
):
126 """Requests encountered an error when trying to rewind a body."""
132 class RequestsWarning(Warning):
133 """Base warning for Requests."""
136 class FileModeWarning(RequestsWarning
, DeprecationWarning):
137 """A file was opened in text mode, but Requests determined its binary length."""
140 class RequestsDependencyWarning(RequestsWarning
):
141 """An imported dependency doesn't match the expected version range."""