aboutsummaryrefslogtreecommitdiff
path: root/requests/packages/urllib3/exceptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'requests/packages/urllib3/exceptions.py')
-rw-r--r--requests/packages/urllib3/exceptions.py28
1 files changed, 18 insertions, 10 deletions
diff --git a/requests/packages/urllib3/exceptions.py b/requests/packages/urllib3/exceptions.py
index c5eb962..2e2a259 100644
--- a/requests/packages/urllib3/exceptions.py
+++ b/requests/packages/urllib3/exceptions.py
@@ -1,5 +1,5 @@
# urllib3/exceptions.py
-# Copyright 2008-2012 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
+# Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
#
# This module is part of urllib3 and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
@@ -20,7 +20,18 @@ class PoolError(HTTPError):
def __reduce__(self):
# For pickling purposes.
- return self.__class__, (None, self.url)
+ return self.__class__, (None, None)
+
+
+class RequestError(PoolError):
+ "Base exception for PoolErrors that have associated URLs."
+ def __init__(self, pool, url, message):
+ self.url = url
+ PoolError.__init__(self, pool, message)
+
+ def __reduce__(self):
+ # For pickling purposes.
+ return self.__class__, (None, self.url, None)
class SSLError(HTTPError):
@@ -35,7 +46,7 @@ class DecodeError(HTTPError):
## Leaf Exceptions
-class MaxRetryError(PoolError):
+class MaxRetryError(RequestError):
"Raised when the maximum number of retries is exceeded."
def __init__(self, pool, url, reason=None):
@@ -47,22 +58,19 @@ class MaxRetryError(PoolError):
else:
message += " (Caused by redirect)"
- PoolError.__init__(self, pool, message)
- self.url = url
+ RequestError.__init__(self, pool, url, message)
-class HostChangedError(PoolError):
+class HostChangedError(RequestError):
"Raised when an existing pool gets a request for a foreign host."
def __init__(self, pool, url, retries=3):
message = "Tried to open a foreign host with url: %s" % url
- PoolError.__init__(self, pool, message)
-
- self.url = url
+ RequestError.__init__(self, pool, url, message)
self.retries = retries
-class TimeoutError(PoolError):
+class TimeoutError(RequestError):
"Raised when a socket timeout occurs."
pass