Visual Studio has an option to break automatically into the debugger when an unhandled exception is thrown, does Eclipse have similar functionality?
2 Answers
You are able to define the precise list of Exception you want to have a breakpoint on, even if those exceptions are uncaught (which should be the equivalent of "unhandled
")
-
12What isn't clear here is whether the debugger will break on ANY exception when "Suspend on uncaught exceptions" is checked off. In the example above, does it mean break on any uncaught exceptions of the type "ActivationException", or does it mean break on any uncaught exception of any type? Very poorly described.– JohannCommented Jun 10, 2013 at 14:00
-
@Johann I'm thinking that if you select the plain "Exception" exception then it will. or should.– ChadCommented Feb 16 at 1:10
Go to the breakpoints window, there's a button that looks like J!, there you can set breakpoints for Java exceptions, either caught or uncaught. You can reference classes or use pattern matchers for exception names.
Also, under Window -> Preferences, Select Java -> Debug and there's a checkbox to tell the debugger to break on uncaught exceptions
-
1@JaySullivan It's on the far right, so if the pane is too small, you will need to expand it. It's the circled icon on the top right of the screenshot in the accepted answer. Commented Jul 12, 2015 at 7:51
-
1The Window/Preference/java/debug solution is a really good complement to the accepted answer, this answer deserve more upvotes.– pdemCommented May 18, 2016 at 7:31
-
1You also need:
Subclasses of this exception
checked - got that from here: stackoverflow.com/a/15866667/1599699– AndrewCommented Dec 12, 2017 at 19:51