Details
-
Type:
Code Smell Detection
-
Status: Active
-
Resolution: Unresolved
-
Labels:
-
Message:Extend "java.lang.Exception" or one of its subclasses.
-
Default Severity:Major
-
Impact:Low
-
Likelihood:High
-
Covered Languages:Java
-
Remediation Function:Constant/Issue
-
Constant Cost:10min
-
Analysis Scope:Main Sources
-
PMD:DoNotExtendJavaLangError
Description
java.lang.Error and its subclasses represent abnormal conditions, such as OutOfMemoryError, which should only be encountered by the Java Virtual Machine.
Noncompliant Code Example
public class MyException extends Error { /* ... */ } // Noncompliant
Compliant Solution
public class MyException extends Exception { /* ... */ } // Compliant
Attachments
Issue Links
- is related to
-
SONARJAVA-3440 FN in S1194: Support extending sub-classes of Error
-
- Closed
-