...
| Code Block | ||
|---|---|---|
| ||
private void doSomething() throws IOException {
//...
}
|
Exceptions
ERR07-J-EX0: Classes that sanitize exceptions to comply with a security policy are permitted to translate specific exceptions into more general exceptions. This translation could potentially result in throwing RuntimeException, Exception, or Throwable in some cases, depending on the requirements of the security policy.
...
Throwing RuntimeException, Exception, or Throwable prevents classes from catching the intended exceptions without catching other unintended exceptions as well.
Rule | Severity | Likelihood | Detectable |
|---|
Repairable | Priority | Level | |
|---|---|---|---|
ERR07-J | Low | Likely | Yes |
No | P6 | L2 |
Automated Detection
| Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| CodeSonar |
| JAVA.STRUCT.EXCP.BROAD | Broad throws clause | ||||||
| Klocwork |
| EXC.BROADTHROWS | |||||||
| Parasoft Jtest |
| CERT.ERR07.NTX CERT.ERR07.NTERR | Avoid declaring methods to throw general or unchecked Exception types Do not throw exception types which are too general or are unchecked exceptions | |||||||
| SonarQube |
| S112 | Generic exceptions should never be thrown |
Related Guidelines
Bibliography
...
...