I have to debug large programs with nested function calls. I would like it s.t. whenever an exception occurs I simply halt the execution at that point, within any function I might be in. Then I can try out different corrections for the error and move on.
While I have been using try except, what I need here is that I can halt inside any function, no matter how nested the call to it might be. So, to do it manually I would have to wrap each function's code around a try-except! like so:
def fun1: try: except: pdb.set_trace() And this would be very cumbersome to write. Also since whenever I encounter an exception I go straight to the except block, for large functions this would require me to restart from the beginning, which would be time taking. So basically I have this (ambitious) requirement of running each line of code in it's own try-except block, like:
def func1: try: line1 except: pdb.set_trace() try: line2 except: pdb.set_trace() Is there some automatic, or clever way to rig up such a system? Thanks in advance.