When a Java async closure completes exceptionally (e.g. with RuntimeException), the error is currently caught in the Swift thunk and completed exceptionally on the Java future as a generic Exception:
Future<Void> future = MySwiftLibrary.asyncScheduleThrowing(() -> {
CompletableFuture<Void> failed = new CompletableFuture<>();
failed.completeExceptionally(new RuntimeException("Java async failed"));
return failed;
});
assertThrows(ExecutionException.class, future::get);
Optimally, we should unwrap the ExecutionException in the Swift thunk and rethrow/preserve the underlying RuntimeException as the cause rather than wrapping it in a generic Exception.
When a Java async closure completes exceptionally (e.g. with
RuntimeException), the error is currently caught in the Swift thunk and completed exceptionally on the Java future as a genericException:Optimally, we should unwrap the
ExecutionExceptionin the Swift thunk and rethrow/preserve the underlyingRuntimeExceptionas the cause rather than wrapping it in a genericException.