_, _, tb = sys.exc_info()
tb_info = traceback.extract_tb(tb)
filename, line, func, text = tb_info[-1]
for ex in tb_info:
filename, line, func, text = ex
log.exception(f'An error occurred on line {line} in statement {text}')
Traceback (most recent call last):
File "raising_func.py", line 28, in raising_func
original exception
ExceptionType
+ where False = ...
+ where ...
File "stack_capture.py", line 8, in stack_capture
raising_func()
ExceptionType
Traceback (most recent call last):
File "stack_capture.py", line 8, in stack_capture
raising_func()
ExceptionType