Package com.nfbsoftware.exception
Class NfbRuntimeException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.nfbsoftware.exception.NfbRuntimeException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
XmlDocumentRuntimeException
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classRepresents aruntimeExceptioncode. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Serializable[]The argument array that holds each of the arguments associated with this exception.protected NfbRuntimeException.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
ConstructorsConstructorDescriptionConstructs aruntimeExceptioninstance.NfbRuntimeException(NfbRuntimeException.Code code, Object[] args, String debugInformation, Throwable rootCause) Constructs an runtimeException 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 code.static NfbRuntimeException.CodeGets the MediaMateRuntimeException.Code object with the corresponding code name.Gets the exception code name.Gets the debug information.protected abstract NfbRuntimeException.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.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
-
NfbRuntimeException
public NfbRuntimeException()Constructs aruntimeExceptioninstance. -
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 codeargs- an argument arraydebugInformation- debug informationrootCause- the root cause
-
-
Method Details
-
getDefaultCode
Gets the defaultCode.- Returns:
- the default code
-
getCodeName
Gets the exception code name.- Returns:
- the code name
-
getCode
Gets the exception code.- Returns:
- the code as a
Codeobject
-
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.
-
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 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
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
-