Inspectopedia Help

Prohibited 'Exception' caught

Reports catch clauses that catch an inappropriate exception.

Some exceptions, for example java.lang.NullPointerException or java.lang.IllegalMonitorStateException, represent programming errors and therefore almost certainly should not be caught in production code.

Example:

try { return component.getMousePosition(true) != null; } catch (NullPointerException e) { // warning: Prohibited exception 'NullPointerException' caught return false; }

Use the Prohibited exceptions list to specify which exceptions should be reported.

Inspection options

Option

Type

Default

Prohibited exceptions

StringList

[java.lang.NullPointerException, java.lang.IllegalMonitorStateException, java.lang.ArrayIndexOutOfBoundsException, java.lang.IndexOutOfBoundsException, java.util.ConcurrentModificationException]

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023