23

Possible Duplicate:
break on unhandled exception in pycharm

I'm new in Python and I'm trying to debug my first python program using PyCharm 1.5. I want debugger to break when exception occurs in my code (and only in mine).

For now the situation is following: I use (Ctrl + Shift + F8 ) Dialog to configure debugger and If i set Suspend All = true and All exceptions = true then debugger breaks far too often, for example, it breaks somewhere inside PyCharm 1.5.1\helpers\pydev\pydevd.py which is annoying to skip every time. And if I set any other options then debugger does not break even when exception occurs in my code.

PS: By the way, if I just skip breaks in PyCharm 1.5.1\helpers\pydev\pydevd.py then execution continues without visible errors. So I do not understand why it breaks at all

3
  • 2
    If you don't get an answer here it might be worth raising an issue at the Pycharm issue tracker. This looks like it could be a bug. Pycharm probably shouldn't be breaking on exceptions in its own code. Commented Jul 12, 2011 at 3:04
  • Ok, thanks for the advice, I'll post here if I find what's up
    – Alex Ilyin
    Commented Jul 12, 2011 at 8:43
  • did it work when you add a debugger point on any location ? Commented Aug 25, 2011 at 17:20

1 Answer 1

3

One way to tell apart your exceptions from exceptions coming from a library, is to have them derive from a custom class, e.g. if your module is called Foo, you could have

class FooException(Exception):
   pass

and have more specific exceptions derive from this:

class MyMathException(FooException):
   # etc.

Then, in PyCharm, instead of enabling All Exceptions, add FooException to the list of exceptions to break upon.

3
  • I agree with what you said, but usually it is not me who raises an exception
    – Alex Ilyin
    Commented Sep 12, 2011 at 16:30
  • Oh. I'm confused now though, you said "when exception occurs in my code (and only in mine)."
    – UncleZeiv
    Commented Sep 12, 2011 at 17:34
  • Yes, for example, if I call missing method then exception happens in my code but it is not me who throws an exception
    – Alex Ilyin
    Commented Sep 13, 2011 at 17:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.