Is it possible to get the pydev debugger to break on exception?
-
There is a slight peculiarity in the Run->Pydev Manage Python Exception Breakpoints UI, which is that the option appears in both the Python perspective and Debug perspective Run menus but is normally (always?) disabled in the Python one. I don't know why this is, but in any case the option should always be enabled in the Debug perspective. – John Armstrong Jan 09 '12 at 16:38
3 Answers
This was added by the PyDev author, under Run > Manage Python Exception Breakpoints

- 3,457
- 3
- 34
- 37
-
-
22I found that I had to put Eclipse into the debug view for the menu option to be active. – John Salvatier Apr 21 '12 at 18:04
-
On any exception?
If my memory serves me right, in PyDev (in Eclipse) this is possible.
EDIT: went through it again, checked pdb documentation, can't find a way to set an exception breakpoint.
If I may suggest a really crude workaround, but if you must, you can call your program from within a try-except
block, set a breakpoint there, and once it breaks in the except
block just go up the stack and debug your error.
Another edit This functionality has been added to PyDev

- 1
- 1

- 161,610
- 92
- 305
- 395
-
Yeah, on any exception. I can't find any reference to how to do it online. Only mailing list and blog posts from 2006 suggesting it not possible. – Mat Jan 18 '09 at 17:46
-
This workaround is quite ugly but works so you have my vote. Now I would like to know where we can make this feature request. – sorin Jun 16 '10 at 10:16
-
9Just to note, this answer is no longer the correct answer (it's outdated now as this has been added to PyDev: Run > Manage Python Exception Breakpoints). – Fabio Zadrozny Aug 31 '11 at 00:54
I've tried the big try-except trick but it didn't work as expected, you got the stack where it breaks, that is in the except: block, you can't get to the stack where the exception was raised from there, that's pointless.
update: pydev does have break-on-exception facility since 1.6.0, but no UI yet, need some code: https://sourceforge.net/tracker/?func=detail&aid=2970886&group_id=85796&atid=577332

- 167
- 1
- 1
- 8
-
"Just did an initial implementation (no UI for now). The api to use it is: import pydevd pydevd.set_pm_excepthook() or passing the exceptions. i.e.: set_pm_excepthook((IndexError, AssertionError)) This should work when launched in the debugger." – John Salvatier Feb 17 '11 at 00:11