Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/requests/exceptions.py: 89%
37 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
1"""
2requests.exceptions
3~~~~~~~~~~~~~~~~~~~
5This module contains the set of Requests' exceptions.
6"""
7from urllib3.exceptions import HTTPError as BaseHTTPError
9from .compat import JSONDecodeError as CompatJSONDecodeError
12class RequestException(IOError):
13 """There was an ambiguous exception that occurred while handling your
14 request.
15 """
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)
27class InvalidJSONError(RequestException):
28 """A JSON error occurred."""
31class JSONDecodeError(InvalidJSONError, CompatJSONDecodeError):
32 """Couldn't decode the text into json"""
34 def __init__(self, *args, **kwargs):
35 """
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.
40 """
41 CompatJSONDecodeError.__init__(self, *args)
42 InvalidJSONError.__init__(self, *self.args, **kwargs)
45class HTTPError(RequestException):
46 """An HTTP error occurred."""
49class ConnectionError(RequestException):
50 """A Connection error occurred."""
53class ProxyError(ConnectionError):
54 """A proxy error occurred."""
57class SSLError(ConnectionError):
58 """An SSL error occurred."""
61class 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.
67 """
70class 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.
74 """
77class ReadTimeout(Timeout):
78 """The server did not send any data in the allotted amount of time."""
81class URLRequired(RequestException):
82 """A valid URL is required to make a request."""
85class TooManyRedirects(RequestException):
86 """Too many redirects."""
89class MissingSchema(RequestException, ValueError):
90 """The URL scheme (e.g. http or https) is missing."""
93class InvalidSchema(RequestException, ValueError):
94 """The URL scheme provided is either invalid or unsupported."""
97class InvalidURL(RequestException, ValueError):
98 """The URL provided was somehow invalid."""
101class InvalidHeader(RequestException, ValueError):
102 """The header value provided was somehow invalid."""
105class InvalidProxyURL(InvalidURL):
106 """The proxy URL provided is invalid."""
109class ChunkedEncodingError(RequestException):
110 """The server declared chunked encoding but sent an invalid chunk."""
113class ContentDecodingError(RequestException, BaseHTTPError):
114 """Failed to decode response content."""
117class StreamConsumedError(RequestException, TypeError):
118 """The content for this response was already consumed."""
121class RetryError(RequestException):
122 """Custom retries logic failed"""
125class UnrewindableBodyError(RequestException):
126 """Requests encountered an error when trying to rewind a body."""
129# Warnings
132class RequestsWarning(Warning):
133 """Base warning for Requests."""
136class FileModeWarning(RequestsWarning, DeprecationWarning):
137 """A file was opened in text mode, but Requests determined its binary length."""
140class RequestsDependencyWarning(RequestsWarning):
141 """An imported dependency doesn't match the expected version range."""