Class Unchecked

java.lang.Object
net.emustudio.emulib.Unchecked

public final class Unchecked extends Object
Runs actions which can throw checked exceptions, rethrowing them unchanged without declaring them ("sneaky throw").
  • Method Details

    • run

      public static void run(Unchecked.RunnableWhichCanThrow r)
      Runs the action; checked exceptions are rethrown unchanged.
      Parameters:
      r - the action
    • call

      public static <T> T call(Unchecked.CallableWithCanThrow<T> c)
      Calls the action; checked exceptions are rethrown unchanged.
      Type Parameters:
      T - the result type
      Parameters:
      c - the action
      Returns:
      the action result
    • sneakyThrow

      public static <T> T sneakyThrow(Throwable e)
      Throws any exception without declaring it.
      Type Parameters:
      T - the "return" type, allowing return sneakyThrow(e);
      Parameters:
      e - the exception
      Returns:
      never returns