comparison CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/site-packages/requests/exceptions.py @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
comparison
equal deleted inserted replaced
67:0e9998148a16 69:33d812a61356
1 """
2 requests.exceptions
3 ~~~~~~~~~~~~~~~~~~~
4
5 This module contains the set of Requests' exceptions.
6 """
7 from urllib3.exceptions import HTTPError as BaseHTTPError
8
9 from .compat import JSONDecodeError as CompatJSONDecodeError
10
11
12 class RequestException(IOError):
13 """There was an ambiguous exception that occurred while handling your
14 request.
15 """
16
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)
25
26
27 class InvalidJSONError(RequestException):
28 """A JSON error occurred."""
29
30
31 class JSONDecodeError(InvalidJSONError, CompatJSONDecodeError):
32 """Couldn't decode the text into json"""
33
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)
43
44 def __reduce__(self):
45 """
46 The __reduce__ method called when pickling the object must
47 be the one from the JSONDecodeError (be it json/simplejson)
48 as it expects all the arguments for instantiation, not just
49 one like the IOError, and the MRO would by default call the
50 __reduce__ method from the IOError due to the inheritance order.
51 """
52 return CompatJSONDecodeError.__reduce__(self)
53
54
55 class HTTPError(RequestException):
56 """An HTTP error occurred."""
57
58
59 class ConnectionError(RequestException):
60 """A Connection error occurred."""
61
62
63 class ProxyError(ConnectionError):
64 """A proxy error occurred."""
65
66
67 class SSLError(ConnectionError):
68 """An SSL error occurred."""
69
70
71 class Timeout(RequestException):
72 """The request timed out.
73
74 Catching this error will catch both
75 :exc:`~requests.exceptions.ConnectTimeout` and
76 :exc:`~requests.exceptions.ReadTimeout` errors.
77 """
78
79
80 class ConnectTimeout(ConnectionError, Timeout):
81 """The request timed out while trying to connect to the remote server.
82
83 Requests that produced this error are safe to retry.
84 """
85
86
87 class ReadTimeout(Timeout):
88 """The server did not send any data in the allotted amount of time."""
89
90
91 class URLRequired(RequestException):
92 """A valid URL is required to make a request."""
93
94
95 class TooManyRedirects(RequestException):
96 """Too many redirects."""
97
98
99 class MissingSchema(RequestException, ValueError):
100 """The URL scheme (e.g. http or https) is missing."""
101
102
103 class InvalidSchema(RequestException, ValueError):
104 """The URL scheme provided is either invalid or unsupported."""
105
106
107 class InvalidURL(RequestException, ValueError):
108 """The URL provided was somehow invalid."""
109
110
111 class InvalidHeader(RequestException, ValueError):
112 """The header value provided was somehow invalid."""
113
114
115 class InvalidProxyURL(InvalidURL):
116 """The proxy URL provided is invalid."""
117
118
119 class ChunkedEncodingError(RequestException):
120 """The server declared chunked encoding but sent an invalid chunk."""
121
122
123 class ContentDecodingError(RequestException, BaseHTTPError):
124 """Failed to decode response content."""
125
126
127 class StreamConsumedError(RequestException, TypeError):
128 """The content for this response was already consumed."""
129
130
131 class RetryError(RequestException):
132 """Custom retries logic failed"""
133
134
135 class UnrewindableBodyError(RequestException):
136 """Requests encountered an error when trying to rewind a body."""
137
138
139 # Warnings
140
141
142 class RequestsWarning(Warning):
143 """Base warning for Requests."""
144
145
146 class FileModeWarning(RequestsWarning, DeprecationWarning):
147 """A file was opened in text mode, but Requests determined its binary length."""
148
149
150 class RequestsDependencyWarning(RequestsWarning):
151 """An imported dependency doesn't match the expected version range."""