CODSTA.NCE
Never use `Exception', RuntimeException', or `Throwable' in "catch" statement
Description
This rule flags code that tries to "catch" an `Exception', `RuntimeException', or `Throwable'.
`Exception', `RuntimeException', and `Throwable' are too general.
Example
package CODSTA;
public class NCE {
void method () {
try {
} catch (Exception e1) {
}
try {
} catch (RuntimeException e2) {
}
try {
} catch (RuntimeException e3) {
}
}
}
Repair
Deal with subclasses of `Exception', `RuntimeException', and `Throwable' when handling exceptions.
Reference
Warren, Nigel, and Bishop, Philip. Java in Practice. Addison-Wesley, 1999, pp. 68-69.
|