summaryrefslogtreecommitdiff
path: root/pip/_vendor/requests/exceptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'pip/_vendor/requests/exceptions.py')
-rw-r--r--pip/_vendor/requests/exceptions.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/pip/_vendor/requests/exceptions.py b/pip/_vendor/requests/exceptions.py
index cd3c76001..a4ee9d630 100644
--- a/pip/_vendor/requests/exceptions.py
+++ b/pip/_vendor/requests/exceptions.py
@@ -14,15 +14,22 @@ class RequestException(IOError):
"""There was an ambiguous exception that occurred while handling your
request."""
+ def __init__(self, *args, **kwargs):
+ """
+ Initialize RequestException with `request` and `response` objects.
+ """
+ response = kwargs.pop('response', None)
+ self.response = response
+ self.request = kwargs.pop('request', None)
+ if (response is not None and not self.request and
+ hasattr(response, 'request')):
+ self.request = self.response.request
+ super(RequestException, self).__init__(*args, **kwargs)
+
class HTTPError(RequestException):
"""An HTTP error occurred."""
- def __init__(self, *args, **kwargs):
- """ Initializes HTTPError with optional `response` object. """
- self.response = kwargs.pop('response', None)
- super(HTTPError, self).__init__(*args, **kwargs)
-
class ConnectionError(RequestException):
"""A Connection error occurred."""