Skip to content

Conversation

stevensJourney
Copy link
Contributor

Overview

We explicitly annotate certain methods in the Kotlin SDK to indicate that they throw PowerSyncExceptions. This allows the Swift SDK to catch these exceptions when a Kotlin method is invoked from Swift.

Catching exceptions in Swift is easy, but it can be tricky to throw Exceptions which should be handled by the Kotlin SDK from the Swift SDK. One cannot throw the SKIEE translated PowerSyncExceptions from Swift code.

This PR introduces a small helper which throws a PowerSyncException from Kotlin code. In some situations (unfortunately not all) this makes reporting exceptions from Swift to the Kotlin SDK simple.

See the usage in the Swift SDK:
Here
Here

@stevensJourney stevensJourney requested a review from simolus3 April 30, 2025 11:19
@stevensJourney stevensJourney marked this pull request as ready for review April 30, 2025 11:19
Copy link
Contributor

@simolus3 simolus3 left a comment

Choose a reason for hiding this comment

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

LGTM, just want to check if we can move this to :PowerSyncKotlin to hide this from non-Swift clients.

@stevensJourney stevensJourney merged commit a1620cd into main Apr 30, 2025
3 checks passed
@stevensJourney stevensJourney deleted the swiftexception branch April 30, 2025 11:53
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.

2 participants