Skip to content

Instantly share code, notes, and snippets.

@TanAlex
Created May 31, 2019 06:06
Show Gist options
  • Save TanAlex/ca8b108927820588f85d4b9eee6b22d1 to your computer and use it in GitHub Desktop.
Save TanAlex/ca8b108927820588f85d4b9eee6b22d1 to your computer and use it in GitHub Desktop.
[python exception]Python exceptions gists #exception
# 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