Overly broad 'throws' clause
Reports throws clauses with exceptions that are more generic than the exceptions that the method actually throws.
Example:
After the quick-fix is applied:
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.
OverlyBroadThrowsClause- 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.
Configure the inspection:
Use the Maximum number of hidden exceptions to warn field to ignore exceptions, that hide a larger number of other exceptions than specified.
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 declared on methods overriding a library method option to ignore overly broad
throwsclauses in methods that override a library method.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 from the method body and thus are technically not overly broad.
Inspection options
Here you can find the description of settings available for the Overly broad 'throws' clause inspection, and the reference of their default values.
- Maximum number of hidden exceptions to report
Default value:
10- Only warn on RuntimeException, Exception, Error or Throwable
Default value:
Not selected- Ignore exceptions declared on methods overriding a library method
Default value:
Not selected- Ignore exceptions which hide others but are themselves thrown
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:
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: |