Package uk.blankaspect.common.exception2
Class BaseException
java.lang.Object
java.lang.Throwable
java.lang.Exception
uk.blankaspect.common.exception2.BaseException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
LocationException
This class implements a base checked exception.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BaseException
An empty exception that may be tested for identity. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Creates a new instance of an exception with no detail message.BaseException
(String message, Object... replacements) Creates a new instance of an exception with the specified detail message.BaseException
(String message, Throwable cause) Creates a new instance of an exception with the specified detail message and cause.BaseException
(String message, Throwable cause, Object... replacements) Creates a new instance of an exception with the specified detail message and cause. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
createMessage
(String message, Object... replacements) Creates a composite message from the specified message and replacement sequences, and returns the result.static void
throwCause
(Throwable exception) Tests the cause of the specified exception, and throws the causal exception if it is aBaseException
.static void
throwCause
(Throwable exception, boolean traverse) Tests the cause of the specified exception, or, optionally, searches the causal chain of the specified exception, and, if aBaseException
is found, throws it.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Field Details
-
EMPTY
An empty exception that may be tested for identity.
-
-
Constructor Details
-
BaseException
protected BaseException()Creates a new instance of an exception with no detail message. -
BaseException
Creates a new instance of an exception with the specified detail message and cause.- Parameters:
message
- the detail message of the exception.cause
- the underlying cause of the exception, which may benull
.
-
BaseException
Creates a new instance of an exception with the specified detail message.- Parameters:
message
- the detail message of the exception.replacements
- the items whose string representations will replace placeholders inmessage
.
-
BaseException
Creates a new instance of an exception with the specified detail message and cause.- Parameters:
message
- the detail message of the exception.cause
- the underlying cause of the exception, which may benull
.replacements
- the items whose string representations will replace placeholders inmessage
.
-
-
Method Details
-
createMessage
Creates a composite message from the specified message and replacement sequences, and returns the result.- Parameters:
message
- the base message.replacements
- the items whose string representations will replace placeholders inmessage
.- Returns:
- the composite message that was created from
message
andreplacements
.
-
throwCause
Tests the cause of the specified exception, and throws the causal exception if it is aBaseException
.- Parameters:
exception
- the exception of interest.- Throws:
BaseException
- if the cause ofexception
is aBaseException
.
-
throwCause
Tests the cause of the specified exception, or, optionally, searches the causal chain of the specified exception, and, if aBaseException
is found, throws it.- Parameters:
exception
- the exception of interest.traverse
- iftrue
, the causal chain ofexception
will be searched for aBaseException
; otherwise, only the immediate cause will be tested.- Throws:
BaseException
-- if
traverse
isfalse
and the cause ofexception
is aBaseException
, or - if
traverse
istrue
and aBaseException
is found in the causal chain ofexception
.
- if
-