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

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

Issue 24076010: Add 'requests' library to third_party. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/swarm_client
Patch Set: Created 7 years, 3 months 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 DecodeError(HTTPError):
43 "Raised when automatic decoding based on Content-Type fails."
44 pass
45
46
47 ## Leaf Exceptions
48
49 class MaxRetryError(RequestError):
50 "Raised when the maximum number of retries is exceeded."
51
52 def __init__(self, pool, url, reason=None):
53 self.reason = reason
54
55 message = "Max retries exceeded with url: %s" % url
56 if reason:
57 message += " (Caused by %s: %s)" % (type(reason), reason)
58 else:
59 message += " (Caused by redirect)"
60
61 RequestError.__init__(self, pool, url, message)
62
63
64 class HostChangedError(RequestError):
65 "Raised when an existing pool gets a request for a foreign host."
66
67 def __init__(self, pool, url, retries=3):
68 message = "Tried to open a foreign host with url: %s" % url
69 RequestError.__init__(self, pool, url, message)
70 self.retries = retries
71
72
73 class TimeoutError(RequestError):
74 "Raised when a socket timeout occurs."
75 pass
76
77
78 class EmptyPoolError(PoolError):
79 "Raised when a pool runs out of connections and no more are allowed."
80 pass
81
82
83 class ClosedPoolError(PoolError):
84 "Raised when a request enters a pool after the pool has been closed."
85 pass
86
87
88 class LocationParseError(ValueError, HTTPError):
89 "Raised when get_host or similar fails to parse the URL input."
90
91 def __init__(self, location):
92 message = "Failed to parse: %s" % location
93 HTTPError.__init__(self, message)
94
95 self.location = location
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698