Class LocalisedBeanException
Object
Throwable
Exception
AnchorCheckedException
AnchorCombinableException
LocalisedBeanException
- All Implemented Interfaces:
Serializable
Combines a chain of many exceptions into a single exception, searching for an ultimate cause and
incorporating the messages from the chain into a single unified message.
To do this, all nested exceptions are traversed until null is found as a cause.
To determine the message string:
- If the exception is of class
LocalisedBeanException, itsmessageis added as a line. - If the exception is another class, it is not included in the message string, but we keep on traversing.
To determine the cause:
- It finds the deep-most instance of
LocalisedBeanException, and considers its {#link getCause()} as the cause.
- Author:
- Owen Feehan
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionLocalisedBeanException(String message, Throwable cause) Create with a message and a cause. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancanExceptionBeCombined(Throwable exception) Can another exception be combined with this exception?protected booleancanExceptionBeSkipped(Throwable exception) Can another exception be skipped, when we combine with the current exception?protected StringcreateMessageForDescription(String message) Creates a message for the exception from the description.Creates a new {link Throwable} that summarizes this exception and any nested causes of the exception.summarizeIgnoreIdenticalFilePath(Path pathMatch) If there is no nested-set of combinable exceptions, and themessagerelated to this current exception is identical as the passed parameter, then we simply ignore the current exception and promote itsThrowable.getCause().Methods inherited from class org.anchoranalysis.core.exception.combinable.AnchorCombinableException
combineDescriptionsRecursively, findMostDeepCombinableException, getDescription, hasNoCombinableNestedExceptionsMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
LocalisedBeanException
Create with a message and a cause.- Parameters:
message- the message.cause- the cause.
-
-
Method Details
-
canExceptionBeCombined
Description copied from class:AnchorCombinableExceptionCan another exception be combined with this exception?- Specified by:
canExceptionBeCombinedin classAnchorCombinableException- Parameters:
exception- the other exception to check if it can be combined.- Returns:
- true iff this exception is compatible to be combined with the current exception.
-
summarize
Description copied from class:AnchorCombinableExceptionCreates a new {link Throwable} that summarizes this exception and any nested causes of the exception.This can effectively combine a chain of nested exceptions into a single exception without a cause.
- Specified by:
summarizein classAnchorCombinableException- Returns:
- an exception summarizing the current exception, and any causes.
-
summarizeIgnoreIdenticalFilePath
If there is no nested-set of combinable exceptions, and themessagerelated to this current exception is identical as the passed parameter, then we simply ignore the current exception and promote itsThrowable.getCause().e.g. there's no point having two error lines e.g. indicating there's an error at file
SOMEPATH. It's only worthwhile doing this, if there's some extra information, like an include stack.- Parameters:
pathMatch- the path we ignored, if it's localized to the same file (and nowhere else).- Returns:
- a new exception representing a summary of this exception and its nested causes.
-
canExceptionBeSkipped
Description copied from class:AnchorCombinableExceptionCan another exception be skipped, when we combine with the current exception?- Specified by:
canExceptionBeSkippedin classAnchorCombinableException- Parameters:
exception- the other exception to check if it can be skipped.- Returns:
- true iff this exception is compatible to be skipped, when processing the current exception.
-
createMessageForDescription
Description copied from class:AnchorCombinableExceptionCreates a message for the exception from the description.- Specified by:
createMessageForDescriptionin classAnchorCombinableException- Parameters:
message- either a single description, or a combined description- Returns:
- a message describing an error, incorporating description
-