taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit afc1a89342cc21183c26da1dbe0cae6a0684d071
parent 78157b355e5bfa33df3bbbdb3e0658ab0d37ece0
Author: Marc Stibane <marc@taler.net>
Date:   Wed,  8 May 2024 22:26:33 +0200

crash fix 8780

Diffstat:
MTalerWallet1/Backend/WalletBackendError.swift | 2+-
MTalerWallet1/Backend/WalletCore.swift | 22++++++++++++++++++----
2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/TalerWallet1/Backend/WalletBackendError.swift b/TalerWallet1/Backend/WalletBackendError.swift @@ -32,7 +32,7 @@ struct WalletBackendResponseError: Codable { /// Numeric error code defined defined in the GANA gnu-taler-error-codes registry. var code: Int - var when: Timestamp + var when: Timestamp? /// English description of the error code. var hint: String diff --git a/TalerWallet1/Backend/WalletCore.swift b/TalerWallet1/Backend/WalletCore.swift @@ -267,14 +267,28 @@ extension WalletCore { } // switch } // type } // 3 components - } catch { // rethrows - symLog.log(jsonData) // TODO: .error - throw WalletBackendError.deserializationError + return + } catch DecodingError.dataCorrupted(let context) { + print(context) + } catch DecodingError.keyNotFound(let key, let context) { + print("Key '\(key)' not found:", context.debugDescription) + print("codingPath:", context.codingPath) + } catch DecodingError.valueNotFound(let value, let context) { + print("Value '\(value)' not found:", context.debugDescription) + print("codingPath:", context.codingPath) + } catch DecodingError.typeMismatch(let type, let context) { + print("Type '\(type)' mismatch:", context.debugDescription) + print("codingPath:", context.codingPath) + } catch let error { // rethrows + symLog.log(error) // TODO: .error } + throw WalletBackendError.walletCoreError(nil) // TODO: error? } @MainActor private func handleNotification(_ anyCodable: AnyCodable?) throws { - guard let anyPayload = anyCodable else { throw WalletBackendError.deserializationError } + guard let anyPayload = anyCodable else { + throw WalletBackendError.deserializationError + } do { let jsonData = try JSONEncoder().encode(anyPayload) let payload = try JSONDecoder().decode(Payload.self, from: jsonData)