diff options
author | SVN-Git Migration <python-modules-team@lists.alioth.debian.org> | 2015-10-08 13:41:25 -0700 |
---|---|---|
committer | SVN-Git Migration <python-modules-team@lists.alioth.debian.org> | 2015-10-08 13:41:25 -0700 |
commit | 9f376f89bdf80a40914218d64cd9cd61b25f449d (patch) | |
tree | 6205015b49c53a3178573532cfcd10dcd7f2d121 /requests/packages/urllib3/exceptions.py | |
parent | d4aa2de2bb89ca384ad81db731bb99735e1db788 (diff) | |
download | python-requests-9f376f89bdf80a40914218d64cd9cd61b25f449d.tar python-requests-9f376f89bdf80a40914218d64cd9cd61b25f449d.tar.gz |
Imported Upstream version 1.1.0
Diffstat (limited to 'requests/packages/urllib3/exceptions.py')
-rw-r--r-- | requests/packages/urllib3/exceptions.py | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/requests/packages/urllib3/exceptions.py b/requests/packages/urllib3/exceptions.py index 15c9699..c5eb962 100644 --- a/requests/packages/urllib3/exceptions.py +++ b/requests/packages/urllib3/exceptions.py @@ -18,21 +18,36 @@ class PoolError(HTTPError): self.pool = pool HTTPError.__init__(self, "%s: %s" % (pool, message)) + def __reduce__(self): + # For pickling purposes. + return self.__class__, (None, self.url) + class SSLError(HTTPError): "Raised when SSL certificate fails in an HTTPS connection." pass +class DecodeError(HTTPError): + "Raised when automatic decoding based on Content-Type fails." + pass + + ## Leaf Exceptions class MaxRetryError(PoolError): "Raised when the maximum number of retries is exceeded." - def __init__(self, pool, url): + def __init__(self, pool, url, reason=None): + self.reason = reason + message = "Max retries exceeded with url: %s" % url - PoolError.__init__(self, pool, message) + if reason: + message += " (Caused by %s: %s)" % (type(reason), reason) + else: + message += " (Caused by redirect)" + PoolError.__init__(self, pool, message) self.url = url @@ -57,11 +72,16 @@ class EmptyPoolError(PoolError): pass +class ClosedPoolError(PoolError): + "Raised when a request enters a pool after the pool has been closed." + pass + + class LocationParseError(ValueError, HTTPError): "Raised when get_host or similar fails to parse the URL input." def __init__(self, location): message = "Failed to parse: %s" % location - super(LocationParseError, self).__init__(self, message) + HTTPError.__init__(self, message) self.location = location |