Class ThrowableUtils

java.lang.Object
io.servicetalk.utils.internal.ThrowableUtils

public final class ThrowableUtils extends Object
Utilities for working with Throwables.
  • Method Details

    • throwException

      public static <T> T throwException(Throwable t)
      Raises an exception bypassing compiler checks for checked exceptions.
      Type Parameters:
      T - The expected type
      Parameters:
      t - The Throwable to throw.
      Returns:
      nothing actually will be returned from this method because it rethrows the specified exception. Making this method return an arbitrary type makes the caller method easier as they do not have to add a return statement after calling this method.
    • combine

      @Nullable public static Throwable combine(@Nullable Object first, @Nullable Object second)
      Combine two potential Throwables into one. If both parameters are Throwable, the second one will be suppressed by the first one.
      Parameters:
      first - the first argument that can be Throwable.
      second - the second argument that can be Throwable.
      Returns:
      combined Throwable.
    • addSuppressed

      public static Throwable addSuppressed(Throwable original, Throwable suppressed)
      Adds suppressed exception avoiding self-suppression.
      Parameters:
      original - the original Throwable
      suppressed - the Throwable to be suppressed
      Returns:
      the original Throwable