check we have a tb (#21670)

This commit is contained in:
Diogo Gomes 2019-03-05 05:18:25 +00:00 committed by Anders Melchiorsen
parent efa5d5dfe3
commit efe4ce9a05

View File

@ -91,15 +91,15 @@ class LogEntry:
self.first_occured = self.timestamp = record.created
self.level = record.levelname
self.message = record.getMessage()
self.exception = ''
self.root_cause = None
if record.exc_info:
self.exception = ''.join(
traceback.format_exception(*record.exc_info))
_, _, tb = record.exc_info # pylint: disable=invalid-name
# Last line of traceback contains the root cause of the exception
if traceback.extract_tb(tb):
self.root_cause = str(traceback.extract_tb(tb)[-1])
else:
self.exception = ''
self.root_cause = None
self.source = source
self.count = 1