Package com.nfbsoftware.exception
Class NfbCheckedException
java.lang.Object
java.lang.Throwable
java.lang.Exception
com.nfbsoftware.exception.NfbCheckedException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
XmlDocumentCheckedException
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classRepresents acheckedExceptioncode. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Serializable[]The argument array that holds each of the arguments associated with this exception.protected NfbCheckedException.CodeThe error code of this exception class.protected StringDebug information related to this exception class.protected ThrowableThe root cause of this exception class.protected intThe severity of this exception class.protected StringThe stack trace of this exception class as a String.protected static final StringThe MessageFormat used by the toString method. -
Constructor Summary
ConstructorsConstructorDescriptionNfbCheckedException(NfbCheckedException.Code code, Object[] args, String debugInformation, Throwable rootCause, int severity) Constructs an MediaMateCheckedException instance with the specified code, args, debugInformation and severity. -
Method Summary
Modifier and TypeMethodDescriptiongetArgs()Gets the argument array associated with the exception code.getCode()Gets the exception codestatic NfbCheckedException.CodeGets the MediaMateCheckedException.Code object with the corresponding code name.Gets the exception code name (aka the error code).Gets the debug information.protected abstract NfbCheckedException.CodeGets the defaultCode.Returns the message based upon the error code and arguments provided to this class as part of the constructor.Gets the severity.intGets the severity.Gets the severity as a String.Gets the stack trace (as a String) of this object if the exception severity is ERROR or FATAL.booleanisSevere()Returnstrueif severity of this exception is ERROR or FATAL.protected static voidRegisters a code object in the code map.toString()Returns a String representation of this object.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Field Details
-
TO_STRING_MESSAGE_FORMAT
The MessageFormat used by the toString method.- See Also:
-
mCode
The error code of this exception class. -
mArgs
The argument array that holds each of the arguments associated with this exception. -
mDebugInformation
Debug information related to this exception class. This is typically set to the class and method name (e.g. Foo.bar). -
mRootCause
The root cause of this exception class. -
mSeverity
protected int mSeverityThe severity of this exception class. -
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 codeargs- an argument arraydebugInformation- debug informationrootCause- the root causeseverity- the severity (based upon the constants defined in the util.Severity class)
-
-
Method Details
-
getDefaultCode
Gets the defaultCode.- Returns:
- the default code
-
getCode
Gets the exception code- Returns:
- the exception code
-
getCodeName
Gets the exception code name (aka the error code).- Returns:
- the code name
-
getArgs
Gets the argument array associated with the exception code.- Returns:
- the arguement array.
-
getDebugInformation
Gets the debug information.- Returns:
- the debug information.
-
getRootCause
Gets the severity.- Returns:
- the severity.
-
getSeverity
public int getSeverity()Gets the severity.- Returns:
- the severity.
-
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
Returns the message based upon the error code and arguments provided to this class as part of the constructor.- Overrides:
getMessagein classThrowable- Returns:
- the message.
-
isSevere
public boolean isSevere()Returnstrueif severity of this exception is ERROR or FATAL. Returnsfalseotherwise.- Returns:
trueif the severity of this exception is ERROR or FATAL;falseotherwise.
-
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
Returns a String representation of this object. e.g.[ERROR - 2002 - ContractTypeDao.find No records found in table: CONTRACTS] -
getCode
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
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
-