Break when exception is thrown
Asked Answered
A

2

254

Visual Studio has an option to break automatically into the debugger when an unhandled exception is thrown, does Eclipse have similar functionality?

Audraaudras answered 17/6, 2010 at 22:52 Comment(2)
Would #588112 help?Kellene
good one, I didnt 'catch' that in my pre-post searchingAudraaudras
K
320

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")

uncaught

Kellene answered 17/6, 2010 at 23:15 Comment(2)
What 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.Pitre
@Pitre I'm thinking that if you select the plain "Exception" exception then it will. or should.Rectus
A
54

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

Aspinwall answered 17/6, 2010 at 23:11 Comment(3)
@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.Hypertonic
The Window/Preference/java/debug solution is a really good complement to the accepted answer, this answer deserve more upvotes.Goddord
You also need: Subclasses of this exception checked - got that from here: https://mcmap.net/q/111525/-how-can-i-make-eclipse-to-break-on-all-uncaught-exceptionsIzaak

© 2022 - 2024 — McMap. All rights reserved.