org.sonar.l10n.java.rules.squid.S1163.html Maven / Gradle / Ivy
The newest version!
Throwing an exception from within a finally block will mask any exception which was previously thrown in the try
or catch
block.
The masked's exception message and stack trace will be lost.
The following code:
try {
/* some work which end up throwing an exception */
throw new IllegalArgumentException();
} finally {
/* clean up */
throw new RuntimeException(); // Non-Compliant - will mask the IllegalArgumentException
}
should be refactored into:
try {
/* some work which end up throwing an exception */
throw new IllegalArgumentException();
} finally {
/* clean up */ // Compliant
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy