I followed this answer and implemented the following:
def B():
try:
raise Exception()
except Exception as e:
traceback_ob = e.__traceback__
import traceback
traceback_str = ''.join(traceback.format_exception(etype=type(e), value=e, tb=traceback_ob))
print(traceback_str)
def A():
B()
A()
The output was:
Traceback (most recent call last):
File "/path/bespoke_traceback.py", line 3, in B
raise Exception()
Exception
I need to have the full trace, so including A in the string - how can I achieve this?
To be specific - I need this in a string, not just printed.