org.sonar.l10n.java.rules.squid.S00112.html Maven / Gradle / Ivy
The newest version!
Using such generic exceptions as Error
, RuntimeException
, Throwable
, and Exception
prevents calling methods from handling true, system-generated exceptions differently than application-generated errors.
Noncompliant Code Example
public void foo(String bar) throws Throwable { // Non-Compliant
throw new RuntimeException("My Message"); // Non-Compliant
}
Compliant Solution
public void foo(String bar) {
throw new MyOwnRuntimeException("My Message");
}
Exceptions
Generic exceptions in the signatures of overriding methods are ignored.
@Override
public void myMethod() throws Exception {...}
See
- MITRE, CWE-397 - Declaration of Throws for Generic Exception
© 2015 - 2025 Weber Informatics LLC | Privacy Policy