Overly broad 'catch' block
Reports catch
blocks with parameters that are more generic than the exception thrown by the corresponding try
block.
Example:
After the quick-fix is applied:
Configure the inspection:
Use the Only warn on RuntimeException, Exception, Error or Throwable option to have this inspection warn only on the most generic exceptions.
Use the Ignore exceptions which hide others but are themselves thrown option to ignore any exceptions that hide other exceptions but still may be thrown and thus are technically not overly broad.
Inspection options
Option | Type | Default |
---|---|---|
Only warn on RuntimeException, Exception, Error or Throwable | Checkbox | false |
Ignore exceptions which hide others but are themselves thrown | Checkbox | false |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |