3

I have Visual Studio 2015 with Python Tools, and I'm trying to debug a python application, but it doesn't break on a certain error.

The error is an IndexError, which can be reproduced with this code:

matrix = [5, 6, 7]
print matrix[2]
print matrix[5000]

Running this will gives me a message in the console, but it won't automatically break. Console message

On the other hand, if I have a NameError:

nonExistingFunction()

It does break, allowing me to easily see where it wrong... It can break the code apparently

Is this normal? And is there a way to make visual studio break when there's an error like that IndexError?

Here is a screenshot of the options window (no idea if this actually applies to python) and the python tools > debugging

My settings for debugging, if that helps My settings for python tools > debugging

1 Answer 1

5

Take a look at the documentation of PVTS in the category exceptions.

If an error occurs while your program is being debugged, and you don't have an exception handler for it, the debugger will break and show you the error.

enter image description here

A section later they say:

If you are being interrupted often by the debugger breaking on exceptions, or if the debugger is not breaking on some exceptions that you would like it to break on, you can modify the settings in the Exceptions window. On the Debug menu, click Exceptions, and expand the Python Exceptions entry. Here you can see all the exceptions that are already know and can be configured.

For Visual Studio 2017,

The Debug > Windows > Exception Settings menu command brings up a window in which you can expand Python Exceptions:

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

I have never used that window before, and it was always there... I guess that's visual studio, so full of features that you'll never run out of new things to learn. Thanks. I'll accept your answer as soon as I can (apparently there's a time limit to how soon you accept answers).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.