'Java's CompletableFuture : time of ExecutionException
When working with CompletableFuture any potential errors from computing the value are exposed via the get() method throwing an ExecutionException. I can of course log this exception at the time of calling this method, but it would be misleading as this exception may have happened at a completely different time from the current.
In short, I would like information on when the ExecutionException occurred.
Is there any elegant solution to this ?
Solution 1:[1]
Use callback methods, i.e. exceptionally, whenComplete or handle, which pass a Throwable and a result.
Solution 2:[2]
Try to wrap execution code into try-catch, which you passed to CompletableFuture.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | KavboiHaggis |
| Solution 2 | KavboiHaggis |
