Home > Enterprise >  Unable to throw exception in Intelj Debug Mode
Unable to throw exception in Intelj Debug Mode

Time:04-05

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?

CodePudding user response:

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

CodePudding user response:

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.

  • Related