code: public static <T> Throwable getException(CompletableFuture<T> future) {
          try {            
              future.getNow(null);
              return null;
          } catch (Exception e) {
              return Exceptions.unwrap(e);
          }
      }
docs: If the future has failed returns the exception that caused it. Otherwise returns null.
  
  @param <T> The Type of the future's result.
  @param future   The future to inspect.
  @return null or the exception that caused the Future to fail.