Class BaseException

java.lang.Object
java.lang.Throwable
java.lang.Exception
uk.blankaspect.common.exception2.BaseException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
LocationException

public class BaseException extends Exception
This class implements a base checked exception.
See Also:
  • Field Details

    • EMPTY

      public static final BaseException 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

      public BaseException(String message, Throwable cause)
      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 be null.
    • BaseException

      public BaseException(String message, Object... replacements)
      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 in message.
    • BaseException

      public BaseException(String message, Throwable cause, Object... replacements)
      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 be null.
      replacements - the items whose string representations will replace placeholders in message.
  • Method Details

    • createMessage

      public static String createMessage(String message, Object... replacements)
      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 in message.
      Returns:
      the composite message that was created from message and replacements.
    • throwCause

      public static void throwCause(Throwable exception) throws BaseException
      Tests the cause of the specified exception, and throws the causal exception if it is a BaseException.
      Parameters:
      exception - the exception of interest.
      Throws:
      BaseException - if the cause of exception is a BaseException.
    • throwCause

      public static void throwCause(Throwable exception, boolean traverse) throws BaseException
      Tests the cause of the specified exception, or, optionally, searches the causal chain of the specified exception, and, if a BaseException is found, throws it.
      Parameters:
      exception - the exception of interest.
      traverse - if true, the causal chain of exception will be searched for a BaseException; otherwise, only the immediate cause will be tested.
      Throws:
      BaseException -
      • if traverse is false and the cause of exception is a BaseException, or
      • if traverse is true and a BaseException is found in the causal chain of exception.