Search code examples
pythonvisual-studio-codevscode-debugger

How to prevent python debugger in Visual Studio Code from stopping within try catch/except statement


I am trying to figure out how to set the python debugger (IntelliSense Pylance downloaded as extension in vscode) to not stop for errors within a try except statement.

For example, in the code below x gets divided by 0 each iteration throwing an error each time:

for x in range(0,10):
    try:
        print(x/0)
    except:
        print("could not perform division")

When I run this code through my debugger I get this message every loop, which is undesirable: enter image description here

Basically how can I prevent the debugger from stopping for errors after a try statement?

I appreciate the help!


Solution

  • Figured it out. If you open the run and debug pane there is a breakpoints list at the bottom with check boxes indicating when or when not to stop the code. Just uncheck the Raised Exceptions box.

    enter image description here