Skip to content

Improved error handling in JExtract JNI mode - #928

Open
madsodgaard wants to merge 9 commits into
swiftlang:mainfrom
madsodgaard:better-errors-jni
Open

madsodgaard wants to merge 9 commits into
swiftlang:mainfrom
madsodgaard:better-errors-jni

Conversation

@madsodgaard

@madsodgaard madsodgaard commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #826

Currently, the only way to handle specific errors in the JExtract JNI mode, is to do a string "contains" against the Exception message. This is quite flakey, and not a nice experience for Java developers.

This PR makes extracted Error types extend Exception itself, which means Java developers can catch Swift errors as normal Java exceptions. For typed throws we also explicitly can state that the Java method throws a specific exception.

Also introduces a AnySwiftError, which is thrown when we cannot extract a concrete user Error type.

@madsodgaard
madsodgaard requested a review from ktoso as a code owner October 5, 2026 11:15
@madsodgaard
madsodgaard requested a review from ktoso October 8, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better support for Error type in JNI mode.

2 participants