Inspectopedia 2025.3 Help

Overly broad 'catch' block

Reports catch blocks with parameters that are more generic than the exception thrown by the corresponding try block.

Example:

try { File file = new File(pathToFile); return file.getAbsolutePath(); } catch (Exception ex) { // warning: 'catch' of 'Exception' is too broad, masking exceptions 'RuntimeException' return defaultFilePath; }

After the quick-fix is applied:

try { File file = new File(pathToFile); return file.getAbsolutePath(); } catch (RuntimeException ex) { return defaultFilePath; }

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

OverlyBroadCatchBlock
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Java | Error handling

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 ID: TooBroadCatch

Inspection options

Here you can find the description of settings available for the Overly broad 'catch' block inspection, and the reference of their default values.

Only warn on RuntimeException, Exception, Error or Throwable

Option ID:

onlyWarnOnRootExceptions

Default value:

Not selected
Ignore exceptions which hide others but are themselves thrown

Option ID:

ignoreThrown

Default value:

Not selected

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection OverlyBroadCatchBlock

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

IntelliJ IDEA 2025.3, Qodana for JVM 2025.3,

Last modified: 03 December 2025