Inspectopedia Help

Prohibited exception declared

Reports methods that declare an inappropriate exception in their throws clause. For example an exception can be inappropriate because it is overly generic, such as java.lang.Exception or java.lang.Throwable.

Example:

void describeModule(String module) throws Exception {} // warning: Prohibited exception 'Exception' declared

Configure the inspection:

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

  • Use the Ignore exceptions declared on methods overriding a library method option to ignore exceptions declared by methods that override a library method.

Inspection options

Option

Type

Default

Prohibited exceptions

StringList

[java.lang.Throwable, java.lang.Exception, java.lang.Error, java.lang.RuntimeException, java.lang.NullPointerException, java.lang.ClassCastException, java.lang.ArrayIndexOutOfBoundsException]

Ignore exceptions declared on methods overriding a library method

Checkbox

false

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023