In Intellij, how can I throw an exception at a break point?

You can right-click on stacktrace and choose 'Throw Exception'

enter image description here

(Since 2018.1 version. See JetBrains issue: IDEA-148408)


How about placing the throw statement in an if block, and only change the condition, e.g.:

boolean shouldThrowException = false;
// ....
if ( shouldThrowException ) //place breakpoint here
{
    throw new IOException();
}

When you hit the breakpoint, change the value of shouldThrowException to true.


In the 'Debbuger' window 'Frames' section right-click current function and select 'Throw Exception'. Then enter exception you want to throw.

enter image description here