#Exception breakpoint for RuntimeException

1 messages · Page 1 of 1 (latest)

fast pasture
#

I want a breakpoint exception that only breaks when it is an instance of RuntimeException and not a child class of it.

mystic fjordBOT
#

<@&987246527741304832> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#

To set a breakpoint for instances of RuntimeException and not its subclasses, you can use conditional breakpoints in your Java IDE. Here's how you can do it in IntelliJ IDEA:

  1. Open your Java project in IntelliJ IDEA.
  2. Go to the line of code where you want to set the breakpoint.
  3. Right-click on the left-hand side margin of the code editor at that line and select "Add Breakpoint" -> "Exception Breakpoint".
  4. In the Exception Breakpoint dialog, enter java.lang.RuntimeException as the exception class.
  5. Click on the "More..." button to open the additional options.
  6. Check the "Condition" checkbox and enter the following condition:
    !(this instanceof java.lang.RuntimeException)
    
  7. Click "OK" to save the breakpoint.

Now, when you run your program in debug mode and it encounters an instance of RuntimeException that is not a subclass of it, the debugger will break at this breakpoint.

Please note that this solution is specific to IntelliJ IDEA IDE, and other IDEs may have slightly different ways of setting conditional breakpoints for exceptions.

fast pasture
#

ok

#

not what i meant

#

but i foudn the issue

half eagle
#

For future questions, please also add which IDE you are using.