How to abstract catching exceptions CompletableFutures for invoking a method

Ok, I have methods like

  1. CompletableFuture fetchCar(int id);
  2. CompletableFuture runSomething(Something t, Extra d);
  3. CompletableFuture invoke();

and I would like a single method that I can use that does the following such that it converts any synchronous exceptions to be put in the future

private CompletableFuture<Void> invokeSomething(Something something) {
    CompletableFuture<Void> future;
    try {
        future = something.runSomething(t, d);
    } catch(Throwable e) {
        future = new CompletableFuture<Void>();
        future.completeExceptionally(e);
    }

    return future;
}

Please note that I just happend to pick #2 as the example but I would like to make that generic so I can stop typing that as in general it needs to be done once in a while to ensure you handle synch and asynch exceptions the same.

Answer:1

Making a runnable .jar with dependent libraries for dummys.. Can someone outline the steps I have to take to making a runnable .jar with dependent libraries for dummy with Maven and Eclipse. I want ...

When I compile a ruby file to a java class using jrubyc, I get different output when compiling with just jrubyc and with jrubyc --java (to generate the java file) and just javac. Why? Example: First ...

Say I have a 3x4x5x6 java double array a that I unroll into an ArrayList b of length 360 in the following way: for (int i = 0; i<a.length; i++){ for (int j = 0; j<a[0].length; j++){ ...

I am basically making a battleship guessing game where you have to the position of a ship by the click of your mouse. When a position of the ship is guessed correctly it deletes that ship cell from ...