Reputation: 169
I cannot figure out how to do this, and all the tutorials around the web seem only to focus on the retrieval of the result in the case where everything works fine. But how am i supposed to improve the following code to fetch the exceptions when they arise?
Future<?> fooFuture = webserviceEjbService.getWebServiceEjbPort()
.fooAsync(new AsyncHandler<FooResponse>() {
@Override
public void handleResponse(Response<FooResponse> res) {
if (res.isDone()) {
result = res.get().getResponse();
}
});
Upvotes: 0
Views: 787
Reputation: 11280
A Future
's get()
method will throw an ExecutionException
if the computation throws an Exception
. That Exception
is set as the cause of the ExecutionException
.
This allows the thread that inspects the result of the compuatation, to handle exceptions thrown by that computation.
Upvotes: 2