Mercurial > repos > jpayne > bioproject_to_srr_2
comparison requests/exceptions.py @ 7:5eb2d5e3bf22
planemo upload for repository https://toolrepo.galaxytrakr.org/view/jpayne/bioproject_to_srr_2/556cac4fb538
author | jpayne |
---|---|
date | Sun, 05 May 2024 23:32:17 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
6:b2745907b1eb | 7:5eb2d5e3bf22 |
---|---|
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 | |
45 class HTTPError(RequestException): | |
46 """An HTTP error occurred.""" | |
47 | |
48 | |
49 class ConnectionError(RequestException): | |
50 """A Connection error occurred.""" | |
51 | |
52 | |
53 class ProxyError(ConnectionError): | |
54 """A proxy error occurred.""" | |
55 | |
56 | |
57 class SSLError(ConnectionError): | |
58 """An SSL error occurred.""" | |
59 | |
60 | |
61 class Timeout(RequestException): | |
62 """The request timed out. | |
63 | |
64 Catching this error will catch both | |
65 :exc:`~requests.exceptions.ConnectTimeout` and | |
66 :exc:`~requests.exceptions.ReadTimeout` errors. | |
67 """ | |
68 | |
69 | |
70 class ConnectTimeout(ConnectionError, Timeout): | |
71 """The request timed out while trying to connect to the remote server. | |
72 | |
73 Requests that produced this error are safe to retry. | |
74 """ | |
75 | |
76 | |
77 class ReadTimeout(Timeout): | |
78 """The server did not send any data in the allotted amount of time.""" | |
79 | |
80 | |
81 class URLRequired(RequestException): | |
82 """A valid URL is required to make a request.""" | |
83 | |
84 | |
85 class TooManyRedirects(RequestException): | |
86 """Too many redirects.""" | |
87 | |
88 | |
89 class MissingSchema(RequestException, ValueError): | |
90 """The URL scheme (e.g. http or https) is missing.""" | |
91 | |
92 | |
93 class InvalidSchema(RequestException, ValueError): | |
94 """The URL scheme provided is either invalid or unsupported.""" | |
95 | |
96 | |
97 class InvalidURL(RequestException, ValueError): | |
98 """The URL provided was somehow invalid.""" | |
99 | |
100 | |
101 class InvalidHeader(RequestException, ValueError): | |
102 """The header value provided was somehow invalid.""" | |
103 | |
104 | |
105 class InvalidProxyURL(InvalidURL): | |
106 """The proxy URL provided is invalid.""" | |
107 | |
108 | |
109 class ChunkedEncodingError(RequestException): | |
110 """The server declared chunked encoding but sent an invalid chunk.""" | |
111 | |
112 | |
113 class ContentDecodingError(RequestException, BaseHTTPError): | |
114 """Failed to decode response content.""" | |
115 | |
116 | |
117 class StreamConsumedError(RequestException, TypeError): | |
118 """The content for this response was already consumed.""" | |
119 | |
120 | |
121 class RetryError(RequestException): | |
122 """Custom retries logic failed""" | |
123 | |
124 | |
125 class UnrewindableBodyError(RequestException): | |
126 """Requests encountered an error when trying to rewind a body.""" | |
127 | |
128 | |
129 # Warnings | |
130 | |
131 | |
132 class RequestsWarning(Warning): | |
133 """Base warning for Requests.""" | |
134 | |
135 | |
136 class FileModeWarning(RequestsWarning, DeprecationWarning): | |
137 """A file was opened in text mode, but Requests determined its binary length.""" | |
138 | |
139 | |
140 class RequestsDependencyWarning(RequestsWarning): | |
141 """An imported dependency doesn't match the expected version range.""" |