in aws_xray_sdk/core/models/throwable.py [0:0]
def __init__(self, exception, stack, remote=False):
"""
:param Exception exception: the catched exception.
:param list stack: the formatted stack trace gathered
through `traceback` module.
:param bool remote: If False it means it's a client error
instead of a downstream service.
"""
self.id = binascii.b2a_hex(os.urandom(8)).decode('utf-8')
try:
message = str(exception)
# in case there is an exception cannot be converted to str
except Exception:
message = None
# do not record non-string exception message
if isinstance(message, str):
self.message = message
self.type = type(exception).__name__
self.remote = remote
try:
self._normalize_stack_trace(stack)
except Exception:
self.stack = None
log.warning("can not parse stack trace string, ignore stack field.")
if exception:
setattr(exception, '_recorded', True)
setattr(exception, '_cause_id', self.id)