254

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

2

2 Answers 2

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

2
  • 12
    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.
    – Johann
    Commented Jun 10, 2013 at 14:00
  • @Johann I'm thinking that if you select the plain "Exception" exception then it will. or should.
    – Chad
    Commented Feb 16 at 1:10
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

3
  • 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.
    – Nateowami
    Commented Jul 12, 2015 at 7:51
  • 1
    The Window/Preference/java/debug solution is a really good complement to the accepted answer, this answer deserve more upvotes.
    – pdem
    Commented May 18, 2016 at 7:31
  • 1
    You also need: Subclasses of this exception checked - got that from here: stackoverflow.com/a/15866667/1599699
    – Andrew
    Commented Dec 12, 2017 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.