import sys import traceback def raiseNested(): try: print("hallo") raise AttributeError("distracting") except: print("cought") print("ätsch will reraise whatever exception",sys.exc_info()) _,pendingexception,_ = sys.exc_info() if getattr(pendingexception,"hello_submethod"): print("cool to meet you") raise def test_nexted_exception(com=False): try: tothrow = AttributeError("test reraised by called method") setattr(tothrow,"hello_submethod",com) raise tothrow except AttributeError: print("call helper to mittigate exception") raiseNested() print("nocom\n==========") try: test_nexted_exception(False) except: traceback.print_exc() print("\ncom\n==========") try: test_nexted_exception(True) except: traceback.print_exc() print("\nnocom\n==========") try: test_nexted_exception(False) except: traceback.print_exc() print("\ncom\n==========") try: test_nexted_exception(True) except: traceback.print_exc()