Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, response):
try:
self.data = response.json()
msg = "%d: %s" % (response.status_code, self.data)
except ValueError:
msg = "Unknown error: %d(%s)" % (response.status_code, response.reason)
super(GenericException, self).__init__(msg)
def maybe_throw(response):
if not response.ok:
if response.status_code == 404:
raise NotFoundException(response)
else:
e = GenericException(response)
try:
e.data = response.json()
except ValueError:
e.content = response.content
raise e