Replies: 2 comments 1 reply
-
Hi @negora, well, there is more or less :) If you put the text cursor over the Exception (works for both, catch clauses and throws clauses), NetBeans will highlight the lines of code which can throw it. If there is nothing highlighted it should be safe to remove (unless its public). I checked and I don't think that there is a code inspection for that, unless I overlooked something. Could be potentially added I suppose since the functionally is basically already there in some form. |
Beta Was this translation helpful? Give feedback.
-
About this discussion, Can it be converted into a proper issue? (a feature request in this case) Thank you! |
Beta Was this translation helpful? Give feedback.
-
Hi:
Playing around with other IDEs, I've seen that both Eclipse IDE and IntelliJ IDEA are able to show if a checked exception is unnecessary in a
throws
clause. Is there a similar function in NetBeans? By unnecessary I mean that no line in the method's body throws such exception.In all years I've been using NetBeans (17) I never thought about it, sincerely. But that feature has been really useful to remove exceptions (from
throws
clauses) that I left by mistake after big code refactorings.By the way, I want to clarify that Eclipse detects these unnecessary exceptions live, in any kind of method, be it private or non-private. IntelliJ, on his part, detects them live in private methods only. For non-private methods, you need to run a code analysis. To me, the behavior of IntelliJ would be enough.
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions