IntelliJ IDEA doesn't show some thrown Exceptions

Answered

Hey,

when using IntelliJ IDEA, I sometimes don't get any help from the IDE in regards to seing or handling a thrown exception.

Example code:

jsonObject = new JSONObject(stringBuilder.toString());

When I hover over this object, I get this:

org.json.JSONObject public JSONObject(@NotNull String source)
throws org.json.JSONException
Throws:
org.json.JSONException

meaning that, there is definitely an exception there being thrown.

But IDEA doesn't handle it. I neither get a recommendation to add it to the method signature, nor do I get one for catching it. It just doesn't register. This seems to especially happen when using stuff imported from maven.

When I write my own code and throw one, it properly deals with it and shows me I'm not handling the exception.

How can I fix this issue? I don't want ANY exception undhandled, so this has really caused quite some problems when developing and having the program crash on me because of the IDEA not warning me...

 

Best regards and thanks

2
2 comments

Please see the comment on this issue in YouTrack IDEA-241497

Note that you can manage the showing notifications in (Settings / Preferences -> Editor -> Inspections) settings. Probably the options below might help you to handle additional exceptions:

  • Checked exception class.

  • Unchecked exception class.

  • Unchecked exception declared in throws clause.

0
Avatar
Permanently deleted user

Hey,

thank you for your response.

Even when I enable all three of those inspections, I do not get an expected warning/error for the runtime exception.

0

Please sign in to leave a comment.