rspec/rules/S1163/java/rule.adoc
2023-06-12 09:22:59 +02:00

28 lines
653 B
Plaintext

include::../why.adoc[]
[source,java,diff-id=1,diff-type=noncompliant]
----
try {
/* some work which end up throwing an exception */
throw new IllegalArgumentException();
} finally {
/* clean up */
throw new RuntimeException(); // Noncompliant; masks the IllegalArgumentException
}
----
[source,java,diff-id=1,diff-type=compliant]
----
try {
/* some work which end up throwing an exception */
throw new IllegalArgumentException();
} finally {
/* clean up */
}
----
== Resources
* https://wiki.sei.cmu.edu/confluence/x/FTZGBQ[CERT, ERR05-J.] - Do not let checked exceptions escape from a finally block
include::../rspecator.adoc[]