Skip to content

Conversation

@ktoso
Copy link
Collaborator

@ktoso ktoso commented Jan 22, 2026

Previously we'd get a single line or exception's "message". This is not actionable at all usually as the reason may contain more information about the issue.

Making this change was difficult because we need SwiftJava/Throwable to gain open func printStackTrace(_ writer: PrintWriter?) and in order to do that we need to get PrintWriter into that module. So we take it from JavaIO which then causes a cascade of problems related to missing types, so we need to lower them all into SwiftJava/.

As such, this change is 4 lines in the generator, and then TONS OF moving around types and adding StringWriter and PrintWriter so we can use the new API. This is effectively just moving around where we generate the wrappers, and then making use of it.

Since the wrap-java command now is adding comments, some existing types got those as well.

We did not lose any methods in this process.

fatalError("Java call threw unhandled exception: \\(error)\\n\\(sw.toString())")
}
fatalError("Java call threw unhandled exception: \\(error)")
"""
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual™ change, this is what we want to make possible -- everything else in this patch is just moving around types so we're able to generate and use this code.

@ktoso ktoso force-pushed the wip-throwble-better-error-printing-wrap-java branch from c38f06c to 35c8f76 Compare January 22, 2026 11:32
@ktoso ktoso merged commit 8cf1829 into swiftlang:main Jan 23, 2026
49 checks passed
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.

1 participant