Class NfbRuntimeException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
XmlDocumentRuntimeException

public abstract class NfbRuntimeException extends RuntimeException
The single runtime exception class. All checked exceptions encountered within the NFB Software Core must be propogated as an runtimeException.
Author:
Brendan Clemenzi
See Also:
  • Field Details

    • TO_STRING_MESSAGE_FORMAT

      protected static final String TO_STRING_MESSAGE_FORMAT
      The MessageFormat used by the toString method.
      See Also:
    • mCode

      protected NfbRuntimeException.Code mCode
      The error code of this exception class.
    • mArgs

      protected Serializable[] mArgs
      The argument array that holds each of the arguments associated with this exception.
    • mDebugInformation

      protected String mDebugInformation
      Debug information related to this exception class. This is typically set to the class and method name (e.g. Foo.bar).
    • mRootCause

      protected Throwable mRootCause
      The root cause of this exception class.
    • mSeverity

      protected int mSeverity
      The severity of this exception class.
    • mStackTraceString

      protected String mStackTraceString
      The stack trace of this exception class as a String.
  • Constructor Details

    • NfbRuntimeException

      public NfbRuntimeException()
      Constructs a runtimeException instance.
    • NfbRuntimeException

      public NfbRuntimeException(NfbRuntimeException.Code code, Object[] args, String debugInformation, Throwable rootCause)
      Constructs an runtimeException instance with the specified code, args, debugInformation and severity.
      Parameters:
      code - the exception code
      args - an argument array
      debugInformation - debug information
      rootCause - the root cause
  • Method Details

    • getDefaultCode

      protected abstract NfbRuntimeException.Code getDefaultCode()
      Gets the default Code.
      Returns:
      the default code
    • getCodeName

      public String getCodeName()
      Gets the exception code name.
      Returns:
      the code name
    • getCode

      public NfbRuntimeException.Code getCode()
      Gets the exception code.
      Returns:
      the code as a Code object
    • getArgs

      public Serializable[] getArgs()
      Gets the argument array associated with the exception code.
      Returns:
      the arguement array.
    • getDebugInformation

      public String getDebugInformation()
      Gets the debug information.
      Returns:
      the debug information.
    • getRootCause

      public Throwable getRootCause()
      Gets the severity.
      Returns:
      the severity.
    • getSeverity

      public int getSeverity()
      Gets the severity.
      Returns:
      the severity.
    • getSeverityAsString

      public String getSeverityAsString()
      Gets the severity as a String. Returns one of the following:
      • FATAL
      • ERROR
      • WARNING
      • INFO
      • SUCCESS
      • DEBUG
      Returns:
      the severity as a String.
    • getMessage

      public String getMessage()
      Returns the message based upon the error code and arguments provided to this class as part of the constructor.
      Overrides:
      getMessage in class Throwable
      Returns:
      the message.
    • getStackTraceString

      public String getStackTraceString()
      Gets the stack trace (as a String) of this object if the exception severity is ERROR or FATAL. Returns the empty string if the exception severity is not ERROR or FATAL.

      Note, the the stack trace of this object will be the stack trace of the root cause if the exception severity is ERROR or FATAL and this object wraps a root cause.

      Note, the results of the exception toString method are removed from the stack trace string prior to it being returned to the caller.

      Returns:
      the stack trace (as a String) of this object.
    • toString

      public String toString()
      Returns a String representation of this object. e.g.
           [ERROR - 2002 - ContractTypeDao.find
           No records found in table: CONTRACTS]
       
      Overrides:
      toString in class Throwable
      Returns:
      a String representation of this object.
    • getCode

      public static NfbRuntimeException.Code getCode(String codeName)
      Gets the MediaMateRuntimeException.Code object with the corresponding code name. This method returns any codes defined within its subclasses, who register their codes with this class at initialization.
      Parameters:
      codeName - the name of the code to retrieve
      Returns:
      the code matching the name, may be null
    • registerCode

      protected static void registerCode(NfbRuntimeException.Code code)
      Registers a code object in the code map. If a code with an identical code name already exists, a runtime exception is thrown.
      Parameters:
      code - the code to register