Do Not Catch java.lang.Exception
ID |
java.no_catch_generic_exception |
Severity |
high |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Reliability |
Language |
Java |
Tags |
CWE:396, reliability |
Rationale
Catching Exception swallows every checked and unchecked exception, including NullPointerException, ArrayIndexOutOfBoundsException, and other programming errors. This makes error handling unreliable because genuine bugs are silently consumed along with the expected exceptions.
// Bad — catches everything, including programming errors
try {
processFile(path);
} catch (Exception e) {
log.error("failed", e);
}