Created
May 31, 2019 06:06
-
-
Save TanAlex/ca8b108927820588f85d4b9eee6b22d1 to your computer and use it in GitHub Desktop.
[python exception]Python exceptions gists #exception
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/kennethreitz/requests/blob/master/requests/exceptions.py | |
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment