de.caff.generics

## Class WrappedFragileException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - java.lang.RuntimeException
      - - de.caff.generics.WrappedFragileException

- All Implemented Interfaces:
    java.io.Serializable
  Direct Known Subclasses:
    EvaluationException

      public class WrappedFragileException
      extends java.lang.RuntimeException

  A runtime exception wrapper for a checked exception which occurred in places where there is no way to handle it.

  In such cases, this runtime exception is used to wrap the given exception, and thrown instead.

  Since:
    July 06, 2023
  Author:
    Rammi
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `WrappedFragileException(java.lang.Exception exception)` Create a wrapped fragile exception.
    `WrappedFragileException(java.lang.Exception exception, java.lang.String additionalMessage)` Create a wrapped fragile exception with an additional message.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Exception` | `getException()` Get the exception.
    `void` | `rethrow()` Throw the wrapped exception.
    `<E extends java.lang.Exception> void` | `rethrow(java.lang.Class<E> xType)` Rethrow the wrapped exception as an expected type.

    - ### Methods inherited from class java.lang.Throwable

      `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### WrappedFragileException

          public WrappedFragileException(@NotNull
                                         java.lang.Exception exception)

      Create a wrapped fragile exception.
      Parameters:
        `exception` - fragile exception to be wrapped

    - #### WrappedFragileException

          public WrappedFragileException(@NotNull
                                         java.lang.Exception exception,
                                         @NotNull
                                         java.lang.String additionalMessage)

      Create a wrapped fragile exception with an additional message.
      Parameters:
        `exception` - fragile exception to be wrapped
        `additionalMessage` - additional message

  - ### Method Detail

    - #### getException

          @NotNull
          public java.lang.Exception getException()

      Get the exception.
      Returns:
        wrapped exception

    - #### rethrow

          public void rethrow()
                       throws java.lang.Exception

      Throw the wrapped exception.
      Throws:
        `java.lang.Exception` - the original exception

    - #### rethrow

          public <E extends java.lang.Exception> void rethrow(@NotNull
                                                              java.lang.Class<E> xType)
                                                       throws E extends java.lang.Exception

      Rethrow the wrapped exception as an expected type. If the wrapped `exception` is not of the correct type this method will throw a `ClassCastException`.
      Type Parameters:
        `E` - expected type
      Parameters:
        `xType` - expected type as class
      Throws:
        `E` - expected exception type
        `java.lang.ClassCastException` - if wrapped exception is of a different type
        `E extends java.lang.Exception`