Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to debug on exceptions inside try except block?

The PyCharm debugger has the feature to set breakpoints at raised exceptions. However if an exception is handled inside a try except block it is not raised. How to deal with this if I want to debug within the try block? I could comment out the try except parts but this seems too cumbersome. Is there a better solution?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

In the breakpoints settings (Either the breakpoint symbol icon in the debug toolbar, or ctrl+shft+F8), you can set exception breakpoints.

The "Activation Policy" is usually set by default to "On termination". But since you handle the error, there is no termination. To activate the breakpoint immediately, even if the error is handled, you need to set the activation policy to "On raise":

showing the activation policy part in the settings, with On raise set

Note: that warning sign which says: "This option may slow down the debugger"

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading