code: @SneakyThrows(Exception.class)
      public static <T, R> R runOrFail(Callable<R> callable, CompletableFuture<T> future) {
          try {
              return callable.call();
          } catch (Throwable t) {
              future.completeExceptionally(t);
              throw t;
          }
      }
docs: Runs the provided Callable in the current thread (synchronously) if it throws any Exception or
  Throwable the exception is propagated, but the supplied future is also failed.
  
  @param <T>      The type of the future.
  @param <R>      The return type of the callable.
  @param callable The function to invoke.
  @param future   The future to fail if the function fails.
  @return The return value of the function.