Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-1194

"java.lang.Error" should not be extended

    XMLWordPrintable

    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

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              freddy.mallet Freddy Mallet (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated: