From a06f04022fb6f514d5e164fba99db09aaba26c8c Mon Sep 17 00:00:00 2001 From: stevensJourney Date: Wed, 30 Apr 2025 13:12:07 +0200 Subject: [PATCH 1/2] add exception helper --- CHANGELOG.md | 1 + .../kotlin/com/powersync/PowerSyncException.kt | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03a76802..b61a2ad4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Fixed `CrudBatch` `hasMore` always returning false. * Added `triggerImmediately` to `onChange` method. +* [Internal] Added helper method for Swift `PowerSyncException` throwing. ## 1.0.0-BETA32 diff --git a/core/src/commonMain/kotlin/com/powersync/PowerSyncException.kt b/core/src/commonMain/kotlin/com/powersync/PowerSyncException.kt index 0ac7a40d..eb1c4757 100644 --- a/core/src/commonMain/kotlin/com/powersync/PowerSyncException.kt +++ b/core/src/commonMain/kotlin/com/powersync/PowerSyncException.kt @@ -4,3 +4,16 @@ public class PowerSyncException( message: String, cause: Throwable, ) : Exception(message, cause) + + +/** + * Helper class designed to bridge SKIEE methods and allow them to throw + * `PowerSyncException`. This is necessary because these exceptions cannot + * be thrown directly in Swift. + * + * The class provides a mechanism to handle exceptions in a way that is + * compatible with the Swift environment, ensuring proper error propagation + * and handling. + */ +@Throws(PowerSyncException::class) +public fun throwPowerSyncException(exception: PowerSyncException): Unit = throw exception From 6f07c58af9bf08c1e7a54f30f76f715fc04a7499 Mon Sep 17 00:00:00 2001 From: stevensJourney Date: Wed, 30 Apr 2025 13:33:57 +0200 Subject: [PATCH 2/2] move throwPowerSyncException --- .../src/appleMain/kotlin/com/powersync/SDK.kt | 14 ++++++++++++-- .../kotlin/com/powersync/PowerSyncException.kt | 13 ------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/PowerSyncKotlin/src/appleMain/kotlin/com/powersync/SDK.kt b/PowerSyncKotlin/src/appleMain/kotlin/com/powersync/SDK.kt index 05e8dc8d..4a22591c 100644 --- a/PowerSyncKotlin/src/appleMain/kotlin/com/powersync/SDK.kt +++ b/PowerSyncKotlin/src/appleMain/kotlin/com/powersync/SDK.kt @@ -1,5 +1,15 @@ -@file:Suppress("ktlint:standard:no-empty-file") - // This is required to build the iOS framework package com.powersync + +/** + * Helper class designed to bridge SKIEE methods and allow them to throw + * `PowerSyncException`. This is necessary because these exceptions cannot + * be thrown directly in Swift. + * + * The class provides a mechanism to handle exceptions in a way that is + * compatible with the Swift environment, ensuring proper error propagation + * and handling. + */ +@Throws(PowerSyncException::class) +public fun throwPowerSyncException(exception: PowerSyncException): Unit = throw exception diff --git a/core/src/commonMain/kotlin/com/powersync/PowerSyncException.kt b/core/src/commonMain/kotlin/com/powersync/PowerSyncException.kt index eb1c4757..0ac7a40d 100644 --- a/core/src/commonMain/kotlin/com/powersync/PowerSyncException.kt +++ b/core/src/commonMain/kotlin/com/powersync/PowerSyncException.kt @@ -4,16 +4,3 @@ public class PowerSyncException( message: String, cause: Throwable, ) : Exception(message, cause) - - -/** - * Helper class designed to bridge SKIEE methods and allow them to throw - * `PowerSyncException`. This is necessary because these exceptions cannot - * be thrown directly in Swift. - * - * The class provides a mechanism to handle exceptions in a way that is - * compatible with the Swift environment, ensuring proper error propagation - * and handling. - */ -@Throws(PowerSyncException::class) -public fun throwPowerSyncException(exception: PowerSyncException): Unit = throw exception