InspectionGadgets: erroneous error reported for wrapped, re-thrown exception

If you catch an Exception (not a Throwable or Error), then re-throw after wrapping in some other exception (whose constructor takes Exception rather than Throwable), IG erroneously reports the error "'throw' inside 'catch' block which ignores the caught exception".

Sure, the JDK 1.4+ exception classes have wrapping ctors which take Throwable, but in practice one almost invariably catches checked exceptions (not Throwables), and wraps them in some application-specific runtime or checked exception. It is therefore natural to design such application-level exceptions to wrap other exceptions rather than throwables.

1 comment
Comment actions Permalink

Good catch. I'll put in a fix in the next version.

--Dave Griffith


Please sign in to leave a comment.