'Unable to throw exception in Intelj Debug Mode

I am debugging a piece of code where I need to throw an exception in try block so that the control goes to catch block. When I am running app using intellij debug mode, when I throw exception by clicking on frame in debugger mode, I see the exception is not getting thrown and the code flow is working normal.What is the reason for this?

try
{
ApiRequest apiRequest = new ApiRequest();
..........
...........

return invoke();
} catch(NoHttpResponseException ex) {
   // debug here
      }
    } 

I have debug points in try block. At any point, i click on debug frame and click throw exception and I type new NoHttpResponseException(), but the catch is not called and the flow after next statement continues.What am I missing here?



Solution 1:[1]

Use Throw Exception action from the 'Frames' context menu: enter image description here

Solution 2:[2]

I wrote similar code as a web service in Intellij Idea and it worked as expected. Here is the code and debug run.

enter image description here

When I go to 'Frames' context menu while debugging and press Throw Exception action I can throw exception when the cursor is in inside invoke method, but in exceptionExample method the same action does not throw exception. It steps into the code. There may be a bug.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andrey
Solution 2