Nested exceptions not logged properly
Closed this issue · 0 comments
ZeroRin commented
Running
try:
raise RuntimeError(1)
except:
raise RuntimeError(2)
results as follows, which is also expected to be the logged info:
Traceback (most recent call last):
File "D:\Workspace\test\test.py", line 2, in <module>
raise RuntimeError(1)
RuntimeError: 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Workspace\test\test.py", line 4, in <module>
raise RuntimeError(2)
RuntimeError: 2
However, running
from logger_tt import logger
try:
try:
raise RuntimeError(1)
except:
raise RuntimeError(2)
except:
logger.exception('Exception')
results as follows
ERROR:root:Exception
Traceback (most recent call last):
File "D:\Workspace\test\test.py", line 7, in <module>
raise RuntimeError(2)
Traceback (most recent call last):
File "D:\Workspace\test\test.py", line 5, in <module>
raise RuntimeError(1)
RuntimeError: 1
During handling of the above exception, another exception occurred:
RuntimeError: 2
The logged exception is in a weird order traceback2 -> traceback1 -> error1 -> error2