A class extends Error, which is meant for failures of the virtual machine

tx0/java:error-subclassstrictwarningsmell

What it finds

Error and its subclasses signal problems a program should not try to handle, such as running out of memory, as the documentation of java.lang.Error says. Application failures that extend it slip past catch (Exception e) handlers and are mistaken for failures of the runtime.

Reported is a class that extends Error.

From the rule's source, error_subclass.rs.

Example from the rule's tests
class ConfigError extends Error {}tx0 reports: extends Error class ConfigException extends Exception {}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/java:error-subclass" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/java:error-subclass] reason="..."

tx0 explain tx0/java:error-subclass shows the same in the terminal. Found a false positive? Report it.