Switching from Eclipse I'm wondering if there is a possibility in IDEA to make a breakpoint that only stops if the statement on its line would throw an exception.
To achieve this in Eclipse I copy the statement into the breakpoint condition and add ; return false;
. Eclipse then stops if there's an exception thrown while evaluating the breakpoint condition.
In IDEA however the condition has to be an expression. When I tried to add a semicolon, IDEA always stated the expression was invalid.
How can I achieve a similar behavior to the one I have in Eclipse or how do you work around this issue?
Remove breakpoints For non-exception breakpoints: click the breakpoint in the gutter. For all breakpoints: from the main menu, select Run | View Breakpoints Ctrl+Shift+F8 , select the breakpoint, and click Remove Delete .
To set a conditional breakpointOn the Home tab, in the Breakpoints group, choose Set/Clear Condition. In the Debugger Breakpoint Condition window, enter a condition. On the Home tab, in the Breakpoints group, choose List. In the Debugger Breakpoint List window, enter a condition in the Condition column.
Conditional breakpoints allow you to break inside a code block when a defined expression evaluates to true. Conditional breakpoints highlight as orange instead of blue. Add a conditional breakpoint by right clicking a line number, selecting Add Conditional Breakpoint , and entering an expression.
Breakpoints are one of the most important debugging techniques in your developer's toolbox. You set breakpoints wherever you want to pause debugger execution. For example, you may want to see the state of code variables or look at the call stack at a certain breakpoint.
I handle such situations by surrounding the statement with a try/catch
clause and putting the breakpoint in the catch block. It requires to recompile your code though.
In Intellij IDEA you can create something called Exception breakpoints
. Maybe it will fulfill your requirements. Exact procedure is described here.
You could combine it with standard Line breakpoint
. For example you could add a Line Breakpoint
on the line of the statement and use an option Disabled until selected breakpoint is hit
and point there at the Exception Breakpoint
activated by required exception class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With