Class InternalErr

  • All Implemented Interfaces:
    java.io.Serializable

    public class InternalErr
    extends java.lang.RuntimeException
    Exception representing internal error in the program caused by programmer error. It should never be caught. We throw this exception to say the system (e.g. some data structure) is in the state, in which it never meant to be when a particular piece of code was written. This is something different from the situation when a user has provided wrong input data.
    This class becomes handy when we do comparison of some value with the enumerator. The following 'enum-match' pattern should be applied: 1. all values of the enumerator should be checked 2. if no matching of the value and enumerator is found, it is a programmer mistake and internal error occurs. It means that when one adds a new enumerator value, one should check every comparison of other values and update them.
     Example:
     enum TypeX { A, B, C }
      
     void doSomething(TypeX value) {
       if (value.equals(TypeX.A) {
          // process A
       } else if (value.equals(TypeX.B) {
          // process C
       } else if (value.equals(TypeX.C) {
          // process C
       } else
         throw InternalErr.error(value);
     }
     
    See Also:
    Serialized Form
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.RuntimeException error()  
      static java.lang.RuntimeException error​(java.lang.Object enumValue)  
      static java.lang.RuntimeException error​(java.lang.String errorMessage)  
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • error

        public static final java.lang.RuntimeException error()
      • error

        public static final java.lang.RuntimeException error​(java.lang.String errorMessage)
      • error

        public static java.lang.RuntimeException error​(java.lang.Object enumValue)