def raiser_g(e): raise e yield 1 def g2(): yield 1 def append_error(e): it = raiser_g(e) try: next(it) except: it2 = g2() next(it2) try: next(it2) except StopIteration: return def main(): append_error(RuntimeError("These exception objects are prepended")) append_error(RuntimeError("to the stack of chained errors")) raise ValueError("HAI WORLD") if __name__ == '__main__': main()