Confused about exceptions during debugging

Answered

When an unhandled exception occurs during debugging, I'm finding it really hard to see what the exception is, at the point it occurs. It seems I can only see the exception message if I let the program run to completion and then look for the exception message in the console window.

Two simple scenarios:

1. I have a a few lines of code that I am going to debug and one of them causes an unhandled exception. If I debug this program with no breakpoints enabled (but I do have the Exception breakpoint turned on for "All exceptions") the debugger will stop on the offending line of code, but the only message in the console is "Breakpoint reached: all exceptions".. how am I supposed to know what the exception is at this point?

2. If I single step through the same few lines of code and I get to the offending line of code and execute it, I see "Breakpoint reached: all exceptions".. but again, no details.

Is there a setting I don't have turned out that can tell me the exception message when it occurs instead of waiting until the program has ended?

In both cases, when I try single stepping after the offending line of code, each single step takes me to the previous location in the call stack, until I eventually wind my way out of the program. This makes sense, but if you are not "expecting" an exception and you are just single stepping your way through code and all of a sudden you are not on the next line of code, but have been popped back in the call stack, it's very confusing

It would be great for pycharm to stop at the point the exception is raised and tell you any exception details it has, let you examine your frame, and then the next single step should take you back in the call stack.

Any input on any of the above would be great!

Thanks

Michael

3 comments

Took me a while to find this page, but I'm glad it's not just me who's amazed at the inability to see any exception details when the IDE breaks on an exception.

0

Hi Mal! Since 2011 many things changed: when debugger breaks at Exception breakpoint, you can see a stack frame (like for every other breakpoint), you can see exception object's fields (variable '__exception__' in the Variables Pane).
Which other details do you want to know? 

0

Ah... it was the "variable '__exception__' in the Variables Pane" bit that I was missing. Thanks.

0

Please sign in to leave a comment.