Back to Intellij Community

BadExceptionThrown

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

2025.3-rc-2491 B
Original Source

Reports throw statements that throw an inappropriate exception. For example an exception can be inappropriate because it is overly generic, such as java.lang.Exception or java.io.IOException.

Example:

void setup(Mode mode) {
      if (mode == null)
          throw new RuntimeException("Problem during setup"); // warning: Prohibited exception 'RuntimeException' thrown
      ...
  }

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