Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: swarm_client/third_party/requests/packages/urllib3/exceptions.py

Issue 69143004: Delete swarm_client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # urllib3/exceptions.py
2 # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
3 #
4 # This module is part of urllib3 and is released under
5 # the MIT License: http://www.opensource.org/licenses/mit-license.php
6
7
8 ## Base Exceptions
9
10 class HTTPError(Exception):
11 "Base exception used by this module."
12 pass
13
14
15 class PoolError(HTTPError):
16 "Base exception for errors caused within a pool."
17 def __init__(self, pool, message):
18 self.pool = pool
19 HTTPError.__init__(self, "%s: %s" % (pool, message))
20
21 def __reduce__(self):
22 # For pickling purposes.
23 return self.__class__, (None, None)
24
25
26 class RequestError(PoolError):
27 "Base exception for PoolErrors that have associated URLs."
28 def __init__(self, pool, url, message):
29 self.url = url
30 PoolError.__init__(self, pool, message)
31
32 def __reduce__(self):
33 # For pickling purposes.
34 return self.__class__, (None, self.url, None)
35
36
37 class SSLError(HTTPError):
38 "Raised when SSL certificate fails in an HTTPS connection."
39 pass
40
41
42 class ProxyError(HTTPError):
43 "Raised when the connection to a proxy fails."
44 pass
45
46
47 class DecodeError(HTTPError):
48 "Raised when automatic decoding based on Content-Type fails."
49 pass
50
51
52 ## Leaf Exceptions
53
54 class MaxRetryError(RequestError):
55 "Raised when the maximum number of retries is exceeded."
56
57 def __init__(self, pool, url, reason=None):
58 self.reason = reason
59
60 message = "Max retries exceeded with url: %s" % url
61 if reason:
62 message += " (Caused by %s: %s)" % (type(reason), reason)
63 else:
64 message += " (Caused by redirect)"
65
66 RequestError.__init__(self, pool, url, message)
67
68
69 class HostChangedError(RequestError):
70 "Raised when an existing pool gets a request for a foreign host."
71
72 def __init__(self, pool, url, retries=3):
73 message = "Tried to open a foreign host with url: %s" % url
74 RequestError.__init__(self, pool, url, message)
75 self.retries = retries
76
77
78 class TimeoutStateError(HTTPError):
79 """ Raised when passing an invalid state to a timeout """
80 pass
81
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
104 class EmptyPoolError(PoolError):
105 "Raised when a pool runs out of connections and no more are allowed."
106 pass
107
108
109 class ClosedPoolError(PoolError):
110 "Raised when a request enters a pool after the pool has been closed."
111 pass
112
113
114 class LocationParseError(ValueError, HTTPError):
115 "Raised when get_host or similar fails to parse the URL input."
116
117 def __init__(self, location):
118 message = "Failed to parse: %s" % location
119 HTTPError.__init__(self, message)
120
121 self.location = location
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698