Class LocalisedBeanException

All Implemented Interfaces:
Serializable

public class LocalisedBeanException extends AnchorCombinableException
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:

  1. If the exception is of class LocalisedBeanException, its message is added as a line.
  2. If the exception is another class, it is not included in the message string, but we keep on traversing.

To determine the cause:

  1. It finds the deep-most instance of LocalisedBeanException, and considers its {#link getCause()} as the cause.
Author:
Owen Feehan
See Also:
  • Constructor Details

    • LocalisedBeanException

      public LocalisedBeanException(String message, Throwable cause)
      Create with a message and a cause.
      Parameters:
      message - the message.
      cause - the cause.
  • Method Details

    • canExceptionBeCombined

      protected boolean canExceptionBeCombined(Throwable exception)
      Specified by:
      canExceptionBeCombined in class AnchorCombinableException
    • summarize

      public Throwable summarize()
      Specified by:
      summarize in class AnchorCombinableException
    • summarizeIgnoreIdenticalFilePath

      public BeanXMLException summarizeIgnoreIdenticalFilePath(Path pathMatch)
      If there is no nested-set of combinable exceptions, and the message related to this current exception is identical as the passed parameter, then we simply ignore the current exception and promote its Throwable.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

      protected boolean canExceptionBeSkipped(Throwable exception)
      Specified by:
      canExceptionBeSkipped in class AnchorCombinableException
    • createMessageForDescription

      protected String createMessageForDescription(String message)
      Specified by:
      createMessageForDescription in class AnchorCombinableException