22 comments
Comment actions Permalink
I'm using the IDEA plugin instead of PyCharm, so the names of your menus might be a little different.

Go to Run > View Breakpoints (or press Cmd+Shift+F8/Strg+Shift+F8). This should open the Breakpoints dialog. On the left side there should be a node Python Exception Breakpoints. Make sure that it has its checkboxes checked. Also, you should have Suspend checked. If it isn't, the debugger won't stop on that breakpoint.

You can find more information about this dialog in the Online help.

I hope that helps!
9
Comment actions Permalink

Has anybody ever found the stop on any exception feature useable?

Whenever I try it, I end up bouncing around in pytest internal exceptions for 15-30 minutes while trying various settings, get tired of wasting my time, and turn it back off.  

I have never been able to get pycharm to quit stopping in library functions.  I don't want my editor polluted by a half dozen library modules and I have no interest in tracing through them.  

As is, my workflow is usually to trace my code and when an exception occurs, I can tell by pycharm bouncing back to the top level call and then into pytest library functions.  I kill it, close all the unwanted editor tabs,  set a breakpoint for the last traceable statement, and try again.  It's 100x faster to keep starting over than to try and get pycharm to break on an exception.

1
Comment actions Permalink

I have the same problem on handling uncaught exceptions in PyCharm 2018.2.4.

The debugger can stop on breakpoints but cannot stop when an exception is raised and then the program terminates without invoking the debugger.

I attach a screenshot of the code and breakpoints configuration.

Are there any other preferences I have to see?

1
Comment actions Permalink

I tried "On raise" check instead of "On termination". In that case, the debugger stops on all exceptions including ones raised in starting scripts or modules used by PyCharm. Therefore, I could not reach my exception even though I resumed the program many times.

1
Comment actions Permalink

Had it set.   Pycharm  still not stopping on exception.

0
Comment actions Permalink

@Adam Pycharm

Could you post a screenshot of your Breakpoints configuration?

0
Comment actions Permalink

This does not work in my pycharm professional 2008.1 build #PY-181.4892.64.  I am running remote python to docker if that makes a difference.

0
Comment actions Permalink

I'd like to add that I'm experiencing the same issue in PyCharm Professional 2018.2.

0
Comment actions Permalink

Could you please provide a code sample? Is the exception unhandled? If it's under try/except you have to enable On raise and Ignore library files options on the screenshot above.

0
Comment actions Permalink

I can't provide a code sample, since I'm working on a proprietary code base. Would a minimal working example (MWE) suffice?

It is not under try/except. It's an unhandled exception.

0
Comment actions Permalink

A minimal example would be sufficient indeed, please feel free to create a ticket in our bug tracker https://youtrack.jetbrains.com/issues/PY or send it to me directly at pavel.karateev@jetbrains.com

So the script just exits with a traceback and the debugger doesn't stop the execution, did I understand you correctly?

0
Comment actions Permalink

Yes, that's correct. I am quite busy today, but I will send you an email with more details on Monday.

0
Comment actions Permalink

I'm experiencing a similar issue in IntelliJ. For some reason when I enable the debugger to stop on "any exception", running my program starts to throw `ClassNotFoundException` for some unknown reason, and it stops there before it appears to even a line of code in my program.

0
Comment actions Permalink

Actually, my problem was that I was enabling it to stop on caught exceptions. I wanted only uncaught exceptions.

Perhaps this is what you are seeking as well.

0
Comment actions Permalink

Hey @Emak.

 

Looking at your debugger setup, I'm wondering. At the bottom right of that window, have you tried changing your "Activation policy" settings? Perhaps if you remove the check for "on termination" and add a check for "on raise", this will do what you need?

0
Comment actions Permalink

Hi Emak,

It is noted in there that This option may slow down the debugger. Could you please file an issue to https://youtrack.jetbrains.com/issues/PY with your idea.log (Help | Show Log in...) after reproducing the problem?

0
Comment actions Permalink

I have solved the issue by adding a "--pdb" flag to the "addition arguments" in the Run/Debug configuration. This starts the debugger whenever a uncaught breakpoint is hit.

0
Comment actions Permalink

I'm having the exact same issue as Emak. Did anyone ever solve it? Okke, I don't have an "addition arguments" field in my Run/Debug Configurations screen. 

0
Comment actions Permalink

By additional arguments, Okke probably meant "interpreter options".

Otherwise, I think your best bet would be to create a bug report on https://youtrack.jetbrains.com/issues/PY , describe the issue in detail and attach logs according to https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files

 

0
Comment actions Permalink

I am having a related problem. My issue is that pycharm is halting in my try catch (so in my handled exception) - which is of course NOT what I want. I was wondering, does anyone know how to have pycharm only halt/break/stop on unhandled exceptions but not on handled ones? Mine is always halting.

Current settings of the breakpoint:

 

btw, cross posted: https://stackoverflow.com/questions/70761481/how-to-stop-pycharms-break-stop-halt-feature-on-handled-exceptions-i-e-only-b and https://intellij-support.jetbrains.com/hc/en-us/community/posts/4415666598546-How-to-stop-PyCharm-s-break-stop-halt-feature-on-handled-exceptions-i-e-only-break-on-python-unhandled-exceptions-

0
Comment actions Permalink

How does one do:

 

```

In your link here intellij-support.jetbrains.com/hc/en-us/community/posts/… the poster Okke said they solved this issue adding --pdb to the 'addition arguments', which someone later said they probably meant interpreter options.

```

 

???

0
Comment actions Permalink

Still does not work, unfortunately, PyCharm 2022.3.2 (Professional Edition).

Jetbrains should really put some effort into actually fixing this (stopping on unhandled exceptions). The debugger is one of the main advantages over VSCode... 

I expect this is a very common scenario and it should really just work out of the box without having to spend countless hours to get it to work (which apparently many people have to do...).

0

Please sign in to leave a comment.