Interface Trap

All Superinterfaces:
ErrorCodeAccessor
All Known Implementing Classes:
AbstractException, AbstractHiddenException, AbstractIOException, AbstractRuntimeException, BugException, DisposedException, IntegrityException, IORuntimeException, LockedException, LockedException.LockedRuntimeException, MarshalException, TimeoutIOException, UnmarshalException, VerifyRuntimeException, VetoException, VetoException.VetoRuntimeException

public interface Trap extends ErrorCodeAccessor
Interface declaring base exception functionality for all of refcodes exceptions.
  • Method Details

    • toMessage

      default String toMessage(MessageDetails aMessageDetails)
      Generates a message using the provided MessageDetails enumeration defining the message's detail level.
      Parameters:
      aMessageDetails - The MessageDetails enumeration defining the message's detail level.
      Returns:
      The according produced Exception's message.
    • toMessage

      default String toMessage(Function<Throwable,String> aMessageFunction)
      Generates a message using the provided Function method producing the message.
      Parameters:
      aMessageFunction - The Function method producing the message.
      Returns:
      The according produced Exception's message.
    • toMessage

      default String toMessage()
      Generates a message by considering a Throwable's cause Throwable.getCause() as well as suppressed Throwable.getSuppressed() exceptions.
      Returns:
      The according more verbose Exception's message.
    • toLocalizedMessage

      default String toLocalizedMessage()
      Generates a localized message by considering a Throwable's Throwable.getCause() cause as well as Throwable.getSuppressed() exceptions.
      Returns:
      The according more verbose Exception's message.
    • toShortMessage

      default String toShortMessage()
      Generates a short message by just considering a Throwable's root cause Throwable.getCause() as well as root Throwable.getSuppressed() exceptions only.
      Returns:
      The according more verbose shorter Exception's message.
    • toShortLocalizedMessage

      default String toShortLocalizedMessage()
      Generates a short localized message by just considering a Throwable's Throwable.getCause() root cause as well as root Throwable.getSuppressed() exceptions only.
      Returns:
      The according more verbose shorter Exception's message.
    • getPatternArguments

      default Object[] getPatternArguments()
      Provides the arguments for the Throwable.getMessage() method to create the actual message from the message pattern (passed as message argument to the exception's constructors). The message pattern together with the arguments are passed to the asMessage(String, Object...) method). Override the getPatternArguments() method to provide the required arguments for applying asMessage(String, Object...) to the message template! Providing null will return the message pattern untouched.
      Returns:
      The arguments required to build a message from the message pattern or null if the message pattern is to be returned directly!
    • asMessage

      static String asMessage(Throwable aException)
      Generates a message by considering the Throwable's cause Throwable.getCause() as well as Throwable.getSuppressed() exceptions.
      Parameters:
      aException - The Throwable from which to produce the message.
      Returns:
      The according more verbose Exception's message.
    • asLocalizedMessage

      static String asLocalizedMessage(Throwable aException)
      Generates a localized message by considering a Throwable's cause Throwable.getCause() as well as Throwable.getSuppressed() exceptions.
      Parameters:
      aException - The Throwable from which to produce the message.
      Returns:
      The according more verbose Exception's message.
    • asShortMessage

      static String asShortMessage(Throwable aException)
      Generates a short message by just considering the Throwable's root cause Throwable.getCause() as well as Throwable.getSuppressed() root exceptions only.
      Parameters:
      aException - The Throwable from which to produce the message.
      Returns:
      The according more verbose Exception's message.
    • asShortLocalizedMessage

      static String asShortLocalizedMessage(Throwable aException)
      Generates a short localized message by just considering a Throwable's root cause Throwable.getCause() as well as Throwable.getSuppressed() root exceptions only.
      Parameters:
      aException - The Throwable from which to produce the message.
      Returns:
      The according more verbose Exception's message.
    • asMessage

      static String asMessage(String aMessage, Throwable aException)
      Creates a message from the provided message and the Exception's contained message(s).
      Parameters:
      aMessage - The message for which to generate the message.
      aException - The Throwable from which to produce the message details.
      Returns:
      The resulting message.
    • asLocalizedMessage

      static String asLocalizedMessage(String aMessage, Throwable aException)
      Creates a message from the provided message and the Exception's contained localized message(s).
      Parameters:
      aMessage - The message for which to generate the message.
      aException - The Throwable from which to produce the message details.
      Returns:
      The resulting message.
    • asMessage

      static String asMessage(String aMessage, Object... aArguments)
      Wraps MessageFormat.format(String, Object...) to prevent failing when message cannot be formatted. Also expands any arrays passed inside the arguments to a comma separated String of the array's elements as of Arrays.toString(Object[]) without the square braces: In case such an expanded array's length is 0, then the according placeholder (such as "{0}", "{1}" and "{2}" and so on) is preserved in the resulting String!
      Parameters:
      aMessage - The message to be formatted by substituting the placeholder ("{0}", "{1}" and "{2}" and so on) with the according arguemtns's elements.
      aArguments - the arguments The arguments which are used for substitution.
      Returns:
      The substituted message.