I have an async function which does a particular task, sample code below,
@Async
public CompletableFuture<Boolean> foo(String value) throws Exception {
// do task
LOGGER.info("Processing completed");
return CompletableFuture.completedFuture(true);
}
Whenever any runtime exception occurs the caller function is not informed and the application runs without any errors/exceptions. This is dangerous because we will be under the false assumption that the processing is successful.
How to avoid this and make the method report error whenever any exception occurs?
To overcome this you need to add an exception try/catch block and set the exception in the completable future instance
On the caller side,