Class SneakyThrower

java.lang.Object
ru.progrm_jarvis.javacommons.util.SneakyThrower

public final class SneakyThrower extends Object
Utility used for rethrowing checked exceptions as unchecked.
  • Method Details

    • sneakyThrow

      public static <X extends Throwable, @Any R> R sneakyThrow(@NonNull X exception)
      Rethrows the provided throwable without the need to handle it. This always throws X never returning any value.
      Type Parameters:
      X - type of the returned exception
      R - any formal return type of this expression
      Parameters:
      exception - rethrown exception
      Returns:
      never