How do you debug exceptions?


I'm debugging an interactive application. The code throws different exceptions when something goes wrong. This means that I usually like to have an exception breakpoint that breaks on any exception. But when I launch the application with that breakpoint enabled, about 30 or 40 exceptions are thrown and caught inside and sun.misc.URLClassPath and the like.

Am I doing something wrong? Or is there a more effective way to debug code that throws exceptions than with a catch-all breakpoint? I'm very used to this approach from other languages and programming environments, so it may just be my habits that get in my way here.

Im using IntelliJ IDEA 9.0.3 on Mac OS X 10.6.4

Thanks for any input!

Comment actions Permalink

In the Breakoints window (Run -> View Breakpoints) you can control which exceptions cause a break into the debugger.

If the breakpoint you need to catch is among those that occur frequenly during start-up, you can make the breakpoint conditional or just keep it disabled until you're into the main loop of your application.

Randall Schulz

Comment actions Permalink

I was afraid of that. This limitation makes it cumbersome when quickly testing some behavior of a library as I don't know beforehand which exceptions and where they will be thrown. This way, it's also very frustrating for users new to Java or programming.

For anyone with the same problem, there is a feature request [0] trying to improve this.




Please sign in to leave a comment.