commit 674b79152950dc59d71e588d1cabcda6a4976ef0
parent 632471e14c769bc4929fc9ca255703492a775915
Author: Marc Stibane <marc@taler.net>
Date: Thu, 5 Nov 2026 13:17:21 +0100
AI: Error handling
Diffstat:
1 file changed, 30 insertions(+), 0 deletions(-)
diff --git a/TalerWallet1/Views/Main/ErrorView.swift b/TalerWallet1/Views/Main/ErrorView.swift
@@ -102,6 +102,26 @@ enum ErrorData {
}
struct ErrorView: View {
+
+ /// wallet-core errors that are expected outcomes, rather than faults, keyed by `TalerErrorCode`.
+ static func titleForExpected(code: Int) -> String? {
+ switch code {
+ case 7054: // WALLET_KYC_LIMIT_EXCEEDED
+ String(localized: "Limit exceeded",
+ comment: "error title: the payment service refused the amount")
+ case 7055: // WALLET_NO_SUITABLE_EXCHANGE
+ String(localized: "No suitable payment service",
+ comment: "error title: no exchange can serve this request")
+ case 7064: // WALLET_CONTRACT_TERMS_UNSUPPORTED
+ String(localized: "Transaction Error")
+ case 7000, // WALLET_EXCHANGE_PROTOCOL_VERSION_INCOMPATIBLE
+ 7017: // WALLET_BANK_INTEGRATION_PROTOCOL_VERSION_INCOMPATIBLE
+ String(localized: "Incompatible version",
+ comment: "error title: the server speaks a protocol this app does not")
+ default: nil
+ }
+ }
+
let stack: CallStack?
var title: String
var exclam: Bool
@@ -152,6 +172,16 @@ struct ErrorView: View {
break
}
let hint = responseError.errorResponse?.hint ?? responseError.hint // nested one preferred
+ // Limits, quotas and similar conditions are ordinary outcomes the user can act on
+ if let expectedTitle = Self.titleForExpected(code: code) {
+ self.init(stack, title: expectedTitle,
+ exclam: false,
+ message: hint,
+ requestUrl: responseError.requestUrl,
+ copyable: devMode,
+ onDismiss: onDismiss)
+ break
+ }
if !devMode, let hint {
// prefer hint for regular users
self.init(stack, title: walletCoreError, message: hint, copyable: true, onDismiss: onDismiss)