Configuring a Conditional Breakpoint in Spyder to Catch When an Error is Raised

93 Views Asked by At

I've been using the debugger in spyder and experimenting with the 'Set/Edit Conditional Breakpoint' functionality. See the code snippet below; where I set the breakpoint condition to i==2 on line 4 the IPdb will pause the code nicely when i is equal to 2 and I can inspect my variables in the variable explorer.

What I'd really like to do is set a conditional breakpoint to only trigger when a certain type of error is raised, therefore allowing me to inspect the variables that caused the error. When I set the conditional breakpoint to simply be: ValueError, it does not trigger when there's an error. Is setting a conditional breakpoint to only trigger when an error is raised possible, and if so, what is the correct syntax?

1  my_list = [1.4, 1.8, 'some text', 4.1]
2
3  for i, value in enumerate(my_list):
4      value_int = int(value)

I've been running this with the following: Spyder==5 & Python==3.10

0

There are 0 best solutions below