Back to Intellij Community

BadExceptionDeclared

java/java-impl/resources/inspectionDescriptions/BadExceptionDeclared.html

2025.3-rc-2622 B
Original Source

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.