
org.sonar.l10n.java.rules.squid.S1162.html Maven / Gradle / Ivy
Even if checked exceptions were thought to be a great feature when they were introduced in Java, their usage progressively became controversial.
In theory, the purpose of checked exceptions is to ensure that errors will be dealt with, either by propagating them or by handling them.
In practice, checked exceptions negatively impact the readability of source code by spreading this error handling/propagation logic everywhere.
This rule verifies that no method throws a checked exception.
Noncompliant Code Example
public void myMethod1() throws CheckedException {
...
throw new CheckedException(message); // Non-Compliant
...
throw new IllegalArgumentException(message); //Compliant as IllegalArgumentException is an unchecked exception
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy