Class KiwiThrowables.ThrowableInfo

java.lang.Object
org.kiwiproject.base.KiwiThrowables.ThrowableInfo
Enclosing class:
KiwiThrowables

@Immutable public static final class KiwiThrowables.ThrowableInfo extends Object
Immutable "struct" that contains information from a Throwable instance.
See Also:
  • Field Details

    • type

      public final String type
    • message

      public final String message
    • stackTrace

      public final String stackTrace
    • cause

      public final Throwable cause
  • Method Details

    • of

      public static KiwiThrowables.ThrowableInfo of(@Nullable Throwable throwable)
      Factory method. If throwable is null, the returned instance will contain all null values, and isEmptyInstance() will return true.
      Parameters:
      throwable - original throwable, possibly null
      Returns:
      constructed instance
    • isEmptyInstance

      public boolean isEmptyInstance()
      Use this method to check whether this instance was created from a null Throwable object.
      Returns:
      true to indicate that this instance was created from a null Throwable; otherwise false
    • hasMessage

      public boolean hasMessage()
      Returns:
      true if the Throwable this instance came from was not null and contained a message, otherwise false
    • hasCause

      public boolean hasCause()
      Returns:
      true if the Throwable this instance came from was not null and had a cause, otherwise false
    • getType

      public Optional<String> getType()
      Returns:
      an Optional containing the type of Throwable this instance came from, or an empty Optional
    • getMessage

      public Optional<String> getMessage()
      Returns:
      an Optional containing the message from the Throwable this instance came from, or an empty Optional
    • getStackTrace

      public Optional<String> getStackTrace()
      Returns:
      an Optional containing the stack trace of the Throwable this instance came from, or an empty Optional
    • getCause

      public Optional<Throwable> getCause()
      Returns:
      an Optional containing the cause from the Throwable this instance came from, or an empty Optional if the original Throwable did not have a cause or this instance came from a null Throwable