Skip to content

jextract: Preserve underlying exception when async closure completes exceptionally #915

Description

@amanmaurya92

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions