in footmark/exception.py [0:0]
def __init__(self, error=None, *args):
Exception.__init__(self, error, *args)
self.error = error
self.request_id = None
self.error_code = None
self.message = ''
self.http_status = ''
if isinstance(self.error, bytes):
try:
self.error = error.decode('utf-8')
except UnicodeDecodeError:
footmark.log.debug('Unable to decode error from bytes!')
# Attempt to parse the error response. If body isn't present,
# then just ignore the error response.
try:
parsed = json.loads(self.error)
if 'request_id' in parsed:
self.request_id = parsed['request_id']
if 'error_code' in parsed:
self.error_code = parsed['error_code']
if 'message' in parsed:
self.message = parsed['message']
if 'http_status' in parsed:
self.http_status = parsed['http_status']
except (TypeError, ValueError):
# Remove unparsable message body so we don't include garbage
# in exception. But first, save self.body in self.error_message
# because occasionally we get error messages from Eucalyptus
# that are just text strings that we want to preserve.
self.message = self.error
self.body = None