rspec/rules/S1166/compliant.adoc

26 lines
488 B
Plaintext
Raw Permalink Normal View History

=== Compliant solution
2022-02-04 17:28:24 +01:00
[source,text]
----
try {
/* ... */
} catch (Exception e) {
LOGGER.info(e); // exception is logged
}
try {
/* ... */
} catch (Exception e) {
throw new RuntimeException(e); // exception stack trace is propagated
}
try {
/* ... */
} catch (RuntimeException e) {
doSomething();
throw e; // original exception passed forward
} catch (Exception e) {
throw new RuntimeException(e); // Conversion into unchecked exception is also allowed
}
----