commit 9278dfcd8e411b42f6d292f88ed01c76a31d1597
parent 2eec5f04339403829bb9fd40e8e2db5dc487aa0c
Author: Marc Stibane <marc@taler.net>
Date: Thu, 16 Jul 2026 18:03:05 +0200
use TalerErrorDetail
Diffstat:
3 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/TalerWallet1/Backend/WalletBackendError.swift b/TalerWallet1/Backend/WalletBackendError.swift
@@ -15,28 +15,28 @@ enum WalletBackendError: Error {
case initializationError
case serializationError
case deserializationError
- case walletCoreError(WalletBackendResponseError?)
+ case walletCoreError(TalerErrorDetail?)
}
/// Information supplied by the backend describing an error.
-struct WalletBackendResponseError: Codable {
- /// Numeric error code defined below (-1..-4)
- var code: Int
- // all other fields are optional:
- var when: Timestamp?
- /// English description of the error code.
- var hint: String?
- /// English diagnostic message that can give details for the instance of the error.
- var message: String?
-
- var requestUrl: String?
-// var httpStatusCode: Int?
-// var requestMethod: String?
-
- var errorResponse: TalerErrorDetail?
-
- var insufficientBalanceDetails: PaymentInsufficientBalanceDetails? = nil
-}
+//struct WalletBackendResponseError: Codable {
+// /// Numeric error code defined below (-1..-4)
+// var code: Int
+// // all other fields are optional:
+// var when: Timestamp?
+// /// English description of the error code.
+// var hint: String?
+// /// English diagnostic message that can give details for the instance of the error.
+// var message: String?
+//
+// var requestUrl: String?
+//// var httpStatusCode: Int?
+//// var requestMethod: String?
+//
+// var errorResponse: TalerErrorDetail?
+//
+// var insufficientBalanceDetails: PaymentInsufficientBalanceDetails? = nil
+//}
struct WalletBackendAbortReason: Codable {
/// Numeric error code defined below (-1..-4)
@@ -52,23 +52,23 @@ struct WalletBackendAbortReason: Codable {
}
extension WalletCore {
- static func serializeRequestError() -> WalletBackendResponseError {
- return WalletBackendResponseError(code: -1, when: Timestamp.now(),
- hint: "Could not serialize request.", message: EMPTYSTRING)
+ static func serializeRequestError() -> TalerErrorDetail {
+ return TalerErrorDetail(code: -1, when: Timestamp.now(),
+ hint: "Could not serialize request.")
}
- static func parseResponseError() -> WalletBackendResponseError {
- return WalletBackendResponseError(code: -2, when: Timestamp.now(),
- hint: "Could not parse response.", message: EMPTYSTRING)
+ static func parseResponseError() -> TalerErrorDetail {
+ return TalerErrorDetail(code: -2, when: Timestamp.now(),
+ hint: "Could not parse response.")
}
- static func parseFailureError() -> WalletBackendResponseError {
- return WalletBackendResponseError(code: -3, when: Timestamp.now(),
- hint: "Could not parse error detail.", message: EMPTYSTRING)
+ static func parseFailureError() -> TalerErrorDetail {
+ return TalerErrorDetail(code: -3, when: Timestamp.now(),
+ hint: "Could not parse error detail.")
}
- static func walletError() -> WalletBackendResponseError {
- return WalletBackendResponseError(code: -4, when: Timestamp.now(),
- hint: "Error detail.", message: EMPTYSTRING)
+ static func walletError() -> TalerErrorDetail {
+ return TalerErrorDetail(code: -4, when: Timestamp.now(),
+ hint: "Error detail.")
}
}
diff --git a/TalerWallet1/Backend/WalletCore.swift b/TalerWallet1/Backend/WalletCore.swift
@@ -29,7 +29,7 @@ class WalletCore: QuickjsMessageHandler {
private let quickjs: Quickjs
private var requestsMade: UInt // counter for array of completion closures
- private var completions: [UInt : (Date, (UInt, Date, String?, Data?, WalletBackendResponseError?) -> Void)] = [:]
+ private var completions: [UInt : (Date, (UInt, Date, String?, Data?, TalerErrorDetail?) -> Void)] = [:]
var delegate: WalletBackendDelegate?
var versionInfo: VersionInfo? // shown in SettingsView
@@ -57,7 +57,7 @@ class WalletCore: QuickjsMessageHandler {
let type: String
let operation: String
let id: UInt
- let error: WalletBackendResponseError
+ let error: TalerErrorDetail
}
var lastError: FullError?
@@ -67,7 +67,7 @@ class WalletCore: QuickjsMessageHandler {
let operation: String?
let id: UInt?
let result: AnyCodable?
- let error: WalletBackendResponseError?
+ let error: TalerErrorDetail?
let payload: AnyCodable?
}
@@ -116,7 +116,7 @@ extension WalletCore {
if let walletError = decoded.error { // wallet-core sent an error message
do {
let jsonData = try JSONEncoder().encode(walletError)
- let responseCode = walletError.errorResponse?.code ?? 0
+ let responseCode = walletError.code
logger.error("wallet-core sent back error \(walletError.code, privacy: .public), \(responseCode, privacy: .public) for request \(requestId, privacy: .public)")
symLog.log("id:\(requestId) \(walletError)")
completion(requestId, timeSent, message, jsonData, walletError)
@@ -451,7 +451,7 @@ extension WalletCore {
}
}
- private func encodeAndSend(_ request: WalletBackendRequest, completionHandler: @escaping (UInt, Date, String?, Data?, WalletBackendResponseError?) -> Void) {
+ private func encodeAndSend(_ request: WalletBackendRequest, completionHandler: @escaping (UInt, Date, String?, Data?, TalerErrorDetail?) -> Void) {
// Encode the request and send it to the backend.
queue.async {
self.semaphore.wait() // guard access to requestsMade
diff --git a/TalerWallet1/Model/Transaction.swift b/TalerWallet1/Model/Transaction.swift
@@ -197,7 +197,7 @@ struct TransactionTransition: Codable { // Notification
var newTxState: TransactionState
var transactionId: String
var experimentalUserData: String? // KYC
- var errorInfo: WalletBackendResponseError?
+ var errorInfo: TalerErrorDetail? // shortened error
}
enum TxAction: String, Codable {