Skip to content
Myr

Move creation of attributes to RequestException

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Pass request objects in HTTPAdapter

authored by Ian Cordasco · committed by Ian Cordasco · parent b1c8fd3 · Browse files · 2 files+14 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+14 added−9 removed

  • other:+14 added−9 removed

2 files+14 added−9 removed

modified:requests/adapters.py+4 added-4 removed
370 unmodified lines
371 # All is well, return the connection to the pool.372 conn._put_conn(low_conn)373374 except socket.error as sockerr:375 raise ConnectionError(sockerr)375 raise ConnectionError(sockerr, request=request)376377 except MaxRetryError as e:378 raise ConnectionError(e)378 raise ConnectionError(e, request=request)379380 except _ProxyError as e:381 raise ProxyError(e)382383 except (_SSLError, _HTTPError) as e:384 if isinstance(e, _SSLError):385 raise SSLError(e)385 raise SSLError(e, request=request)386 elif isinstance(e, TimeoutError):387 raise Timeout(e)387 raise Timeout(e, request=request)388 else:389 raise390391 r = self.build_response(request, resp)
5 unmodified lines
modified:requests/exceptions.py+10 added-5 removed
12 unmodified lines
13class RequestException(IOError):14 """There was an ambiguous exception that occurred while handling your15 request."""1617 def __init__(self, *args, **kwargs):18 """19 Initialize RequestException with `request` and `response` objects.20 """21 self.response = kwargs.pop('response', None)22 self.request = kwargs.pop('request', None)23 if self.response and not self.request:24 self.request = self.response.request25 super(RequestException, self).__init__(*args, **kwargs)262728class HTTPError(RequestException):29 """An HTTP error occurred."""3021 def __init__(self, *args, **kwargs):22 """ Initializes HTTPError with optional `response` object. """23 self.response = kwargs.pop('response', None)24 super(HTTPError, self).__init__(*args, **kwargs)312632class ConnectionError(RequestException):33 """A Connection error occurred."""3435
38 unmodified lines