From 61f154724d4d0b9d40d9201f76ffbda502ae33c5 Mon Sep 17 00:00:00 2001 From: Yuzhe Yan Date: Sun, 1 Nov 2026 15:27:55 +0100 Subject: [PATCH] fix(backup): declare restore failures for Swift callers BackupService.restore rejects invalid files with IllegalArgumentException (kotlinx.serialization's SerializationException, require() checks and SnapshotV3ValidationException all extend it). Without @Throws the exception aborts the process on Apple targets; with it Swift gets restore(raw:) throws and can show an error instead. --- .../commonMain/kotlin/com/deadliner/service/BackupService.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shared/src/commonMain/kotlin/com/deadliner/service/BackupService.kt b/shared/src/commonMain/kotlin/com/deadliner/service/BackupService.kt index 1cff869..e0497c3 100644 --- a/shared/src/commonMain/kotlin/com/deadliner/service/BackupService.kt +++ b/shared/src/commonMain/kotlin/com/deadliner/service/BackupService.kt @@ -25,6 +25,8 @@ class BackupService internal constructor(private val database: AppDatabase) { ), ) + /** Invalid files fail with [IllegalArgumentException] (decoding, format or validation); Swift sees `throws`. */ + @Throws(IllegalArgumentException::class) fun restore(raw: String) { val backup = json.decodeFromString(raw) require(backup.formatVersion == BackupRoot.FORMAT_VERSION) { "Unsupported backup format" }