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)
      Description copied from class: AnchorCombinableException
      Can another exception be combined with this exception?
      Specified by:
      canExceptionBeCombined in class AnchorCombinableException
      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

      public Throwable summarize()
      Description copied from class: AnchorCombinableException
      Creates 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:
      summarize in class AnchorCombinableException
      Returns:
      an exception summarizing the current exception, and any causes.
    • 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)
      Description copied from class: AnchorCombinableException
      Can another exception be skipped, when we combine with the current exception?
      Specified by:
      canExceptionBeSkipped in class AnchorCombinableException
      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

      protected String createMessageForDescription(String message)
      Description copied from class: AnchorCombinableException
      Creates a message for the exception from the description.
      Specified by:
      createMessageForDescription in class AnchorCombinableException
      Parameters:
      message - either a single description, or a combined description
      Returns:
      a message describing an error, incorporating description