Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
343 views
in Technique[技术] by (71.8m points)

java - How to use Intellij Idea's exception breakpoints

This seems a dumb question, but I can't figure out how to debug exceptions in Intellij Idea. Googling does not help either.

I try to create exception breakpoints. When IDEA breaks, I expect it to give me a call stack showing what leads to the method that throws the exception as well as automatic watch window just like Visual Studio's debugging tool. Instead it shows all kinds of garbled message about Launcher or ClassLoader, but no signs of the actual exception during runtime.

So how exactly is IDEA's exception breakpoint supposed to be used?

question from:https://stackoverflow.com/questions/16567136/how-to-use-intellij-ideas-exception-breakpoints

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It works really well and I don't really know what kind of problems you have with Launcher or ClassLoader. It could be that you have selected to catch Any exceptions and this means that it will catch all kinds of exceptions during the startup and class loading as well. You have to make specific choices about what exceptions to catch, or just go through them all until your exception is caught.

Anyhow I will show you how I set up a very simple case and you'll see that it is working really well.

I have a simple case where a NullPointerException will be thrown.

First you'll have to set up the exception breakpoint.

Enter the View Breakpoints... window by pressing Ctrl+Shift+F8. Then press the little + sign in the upper left corner.

enter image description here

Enter NullPointerException and press the OK button.

enter image description here

Make sure that the Any exception is not checked.

Now run the program by right-clicking inside the main method and select Debug 'SomeClass.main()'

enter image description here

And finally watch when the exception is caught and you will have all the things you expected like call stack and watch window.

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...