ch.systemsx.cisd.common.exceptions
Class InternalErr
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
ch.systemsx.cisd.common.exceptions.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 |
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 |
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
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)