Exception Naming Convention
ID |
java.naming_exception |
Severity |
low |
Remediation Complexity |
trivial |
Remediation Risk |
medium |
Remediation Effort |
low |
Resource |
Naming Convention |
Language |
Java |
Tags |
naming |
Description
Reports classes that extend Exception, RuntimeException, or other exception types but whose name does not end with the suffix Exception.
Rationale
Consistent naming is crucial for readability and maintainability. When a class extends an exception type, readers and tools expect the class name to end with Exception. This convention makes exception types immediately recognisable in catch clauses, stack traces, and IDE navigation.
// Bad - name does not end with "Exception"
class NetworkError extends RuntimeException {}
class BadInput extends IllegalArgumentException {}
// Good - name ends with "Exception"
class NetworkException extends RuntimeException {}
class BadInputException extends IllegalArgumentException {}