resources.report.rules.pmd.AvoidCatchingThrowable.html Maven / Gradle / Ivy
AvoidCatchingThrowable
AvoidCatchingThrowable
Catching Throwable errors is not recommended since its scope is very broad. It includes runtime issues such as OutOfMemoryError that should be exposed and managed separately.
This rule is defined by the following Java class: net.sourceforge.pmd.lang.java.rule.strictexception.AvoidCatchingThrowableRule
Example(s):
public void bar() {
try {
// do something
} catch (Throwable th) { // should not catch Throwable
th.printStackTrace();
}
}