OLD | NEW |
1 # urllib3/exceptions.py | 1 # urllib3/exceptions.py |
2 # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt) | 2 # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt) |
3 # | 3 # |
4 # This module is part of urllib3 and is released under | 4 # This module is part of urllib3 and is released under |
5 # the MIT License: http://www.opensource.org/licenses/mit-license.php | 5 # the MIT License: http://www.opensource.org/licenses/mit-license.php |
6 | 6 |
7 | 7 |
8 ## Base Exceptions | 8 ## Base Exceptions |
9 | 9 |
10 class HTTPError(Exception): | 10 class HTTPError(Exception): |
(...skipping 21 matching lines...) Expand all Loading... |
32 def __reduce__(self): | 32 def __reduce__(self): |
33 # For pickling purposes. | 33 # For pickling purposes. |
34 return self.__class__, (None, self.url, None) | 34 return self.__class__, (None, self.url, None) |
35 | 35 |
36 | 36 |
37 class SSLError(HTTPError): | 37 class SSLError(HTTPError): |
38 "Raised when SSL certificate fails in an HTTPS connection." | 38 "Raised when SSL certificate fails in an HTTPS connection." |
39 pass | 39 pass |
40 | 40 |
41 | 41 |
| 42 class ProxyError(HTTPError): |
| 43 "Raised when the connection to a proxy fails." |
| 44 pass |
| 45 |
| 46 |
42 class DecodeError(HTTPError): | 47 class DecodeError(HTTPError): |
43 "Raised when automatic decoding based on Content-Type fails." | 48 "Raised when automatic decoding based on Content-Type fails." |
44 pass | 49 pass |
45 | 50 |
46 | 51 |
47 ## Leaf Exceptions | 52 ## Leaf Exceptions |
48 | 53 |
49 class MaxRetryError(RequestError): | 54 class MaxRetryError(RequestError): |
50 "Raised when the maximum number of retries is exceeded." | 55 "Raised when the maximum number of retries is exceeded." |
51 | 56 |
(...skipping 11 matching lines...) Expand all Loading... |
63 | 68 |
64 class HostChangedError(RequestError): | 69 class HostChangedError(RequestError): |
65 "Raised when an existing pool gets a request for a foreign host." | 70 "Raised when an existing pool gets a request for a foreign host." |
66 | 71 |
67 def __init__(self, pool, url, retries=3): | 72 def __init__(self, pool, url, retries=3): |
68 message = "Tried to open a foreign host with url: %s" % url | 73 message = "Tried to open a foreign host with url: %s" % url |
69 RequestError.__init__(self, pool, url, message) | 74 RequestError.__init__(self, pool, url, message) |
70 self.retries = retries | 75 self.retries = retries |
71 | 76 |
72 | 77 |
73 class TimeoutError(RequestError): | 78 class TimeoutStateError(HTTPError): |
74 "Raised when a socket timeout occurs." | 79 """ Raised when passing an invalid state to a timeout """ |
75 pass | 80 pass |
76 | 81 |
77 | 82 |
| 83 class TimeoutError(HTTPError): |
| 84 """ Raised when a socket timeout error occurs. |
| 85 |
| 86 Catching this error will catch both :exc:`ReadTimeoutErrors |
| 87 <ReadTimeoutError>` and :exc:`ConnectTimeoutErrors <ConnectTimeoutError>`. |
| 88 """ |
| 89 pass |
| 90 |
| 91 |
| 92 class ReadTimeoutError(TimeoutError, RequestError): |
| 93 "Raised when a socket timeout occurs while receiving data from a server" |
| 94 pass |
| 95 |
| 96 |
| 97 # This timeout error does not have a URL attached and needs to inherit from the |
| 98 # base HTTPError |
| 99 class ConnectTimeoutError(TimeoutError): |
| 100 "Raised when a socket timeout occurs while connecting to a server" |
| 101 pass |
| 102 |
| 103 |
78 class EmptyPoolError(PoolError): | 104 class EmptyPoolError(PoolError): |
79 "Raised when a pool runs out of connections and no more are allowed." | 105 "Raised when a pool runs out of connections and no more are allowed." |
80 pass | 106 pass |
81 | 107 |
82 | 108 |
83 class ClosedPoolError(PoolError): | 109 class ClosedPoolError(PoolError): |
84 "Raised when a request enters a pool after the pool has been closed." | 110 "Raised when a request enters a pool after the pool has been closed." |
85 pass | 111 pass |
86 | 112 |
87 | 113 |
88 class LocationParseError(ValueError, HTTPError): | 114 class LocationParseError(ValueError, HTTPError): |
89 "Raised when get_host or similar fails to parse the URL input." | 115 "Raised when get_host or similar fails to parse the URL input." |
90 | 116 |
91 def __init__(self, location): | 117 def __init__(self, location): |
92 message = "Failed to parse: %s" % location | 118 message = "Failed to parse: %s" % location |
93 HTTPError.__init__(self, message) | 119 HTTPError.__init__(self, message) |
94 | 120 |
95 self.location = location | 121 self.location = location |
OLD | NEW |