SwashBuckler001's picture
IdiomBench (part 6)
60f5111 verified
Raw History Blame Contribute Delete
453 Bytes
import traceback
def g(v):
try:
raise ValueError(v)
except Exception as e:
return e
def f():
raise ExceptionGroup("eg", [g(1), g(2)])
try:
f()
except BaseException as e:
eg = e
for (i, (exc, tbs)) in enumerate(leaf_generator(eg)):
print(f"\n=== Exception #{i+1}:")
traceback.print_exception(exc)
print(f"The complete traceback for Exception #{i+1}:")
for tb in tbs:
traceback.print_tb(tb)