Class NfbCheckedException

java.lang.Object
java.lang.Throwable
java.lang.Exception
com.nfbsoftware.exception.NfbCheckedException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
XmlDocumentCheckedException

public abstract class NfbCheckedException extends Exception
The single checked exception class. All checked exceptions encountered within the NFB Software Core must be propagated as a CheckedException.
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 NfbCheckedException.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

    • NfbCheckedException

      public NfbCheckedException()
    • NfbCheckedException

      public NfbCheckedException(NfbCheckedException.Code code, Object[] args, String debugInformation, Throwable rootCause, int severity)
      Constructs an MediaMateCheckedException 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
      severity - the severity (based upon the constants defined in the util.Severity class)
  • Method Details

    • getDefaultCode

      protected abstract NfbCheckedException.Code getDefaultCode()
      Gets the default Code.
      Returns:
      the default code
    • getCode

      public NfbCheckedException.Code getCode()
      Gets the exception code
      Returns:
      the exception code
    • getCodeName

      public String getCodeName()
      Gets the exception code name (aka the error code).
      Returns:
      the code name
    • 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.
    • isSevere

      public boolean isSevere()
      Returns true if severity of this exception is ERROR or FATAL. Returns false otherwise.
      Returns:
      true if the severity of this exception is ERROR or FATAL; false otherwise.
    • 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 NfbCheckedException.Code getCode(String codeName)
      Gets the MediaMateCheckedException.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(NfbCheckedException.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