commit 3add557802b4a5c0a4707259176998d19a9ce7d1
parent df4fe35295fbdac0cc690cdbce63674d432ea64b
Author: Marc Stibane <marc@taler.net>
Date: Thu, 9 Feb 2023 09:24:16 +0100
Error handling, Amount.diff
Diffstat:
9 files changed, 45 insertions(+), 23 deletions(-)
diff --git a/TalerWallet1/Controllers/TalerWallet1App.swift b/TalerWallet1/Controllers/TalerWallet1App.swift
@@ -43,7 +43,7 @@ struct TalerWallet1App: App {
.handlesExternalEvents(preferring: ["*"], allowing: ["*"])
.task {
symLog.log("task -> initWalletCore")
- try? await controller.initWalletCore()
+ try! await controller.initWalletCore() // will (and should) crash on failure
symLog.log("task done")
}
}
diff --git a/TalerWallet1/Model/WalletInitModel.swift b/TalerWallet1/Model/WalletInitModel.swift
@@ -27,12 +27,14 @@ fileprivate struct WalletBackendInitRequest: WalletBackendFormattedRequest {
func operation() -> String { return "init" }
func args() -> Args {
return Args(persistentStoragePath: persistentStoragePath,
- cryptoWorkerType: "sync")
+// cryptoWorkerType: "sync",
+ logLevel: "info") // "trace", "info", "warn", "error", "none"
}
struct Args: Encodable {
var persistentStoragePath: String
- var cryptoWorkerType: String?
+// var cryptoWorkerType: String
+ var logLevel: String
}
var persistentStoragePath: String
diff --git a/TalerWallet1/Views/Balances/CurrenciesListView.swift b/TalerWallet1/Views/Balances/CurrenciesListView.swift
@@ -69,8 +69,13 @@ extension CurrenciesListView {
}
.navigationBarTitleDisplayMode(.large) // .inline
.refreshable {
- symLog?.log("refreshing")
- try? await reloadAction() // TODO: catch error
+ do {
+ symLog?.log("refreshing")
+ try await reloadAction()
+ } catch {
+ // TODO: error
+ symLog?.log(error.localizedDescription)
+ }
}
}
}
diff --git a/TalerWallet1/Views/Exchange/ExchangeListView.swift b/TalerWallet1/Views/Exchange/ExchangeListView.swift
@@ -85,11 +85,11 @@ extension ExchangeListView {
}
.navigationBarTitleDisplayMode(.large) // .inline
.refreshable {
- symLog.log("refreshing")
do {
+ symLog.log("refreshing")
try await reloadAction()
} catch {
- // TODO: catch error
+ // TODO: error
symLog.log(error.localizedDescription)
}
}
diff --git a/TalerWallet1/Views/Payment/PaymentAcceptView.swift b/TalerWallet1/Views/Payment/PaymentAcceptView.swift
@@ -35,7 +35,7 @@ struct PaymentAcceptView: View {
symLog { Group {
let raw = detailsForAmount.amountRaw
let effective = detailsForAmount.amountEffective
- let fee = try! effective - raw
+ let fee = try! Amount.diff(raw, effective) // TODO: different currencies
Form {
AmountView(title: "Amount to pay:",
value: raw.readableDescription, color: Color(UIColor.label))
diff --git a/TalerWallet1/Views/Pending/PendingOpsListView.swift b/TalerWallet1/Views/Pending/PendingOpsListView.swift
@@ -37,7 +37,12 @@ struct PendingOpsListView: View {
}
}.task {
symLog.log(".task")
- try? await reloadAction() // TODO: catch error
+ do {
+ try await reloadAction()
+ } catch {
+ // TODO: show error
+ symLog.log(error.localizedDescription)
+ }
}
}
}
@@ -56,8 +61,13 @@ extension PendingOpsListView {
}
.navigationBarTitleDisplayMode(.large) // .inline
.refreshable {
- symLog?.log("refreshing")
- try? await reloadAction() // TODO: catch error
+ do {
+ symLog?.log("refreshing")
+ try await reloadAction()
+ } catch {
+ // TODO: error
+ symLog?.log(error.localizedDescription)
+ }
}
}
}
diff --git a/TalerWallet1/Views/Transactions/TransactionDetail.swift b/TalerWallet1/Views/Transactions/TransactionDetail.swift
@@ -22,7 +22,7 @@ struct TransactionDetail: View {
var body: some View {
let raw = transaction.amountRaw
let effective = transaction.amountEffective
- let fee = try! Amount.diff(raw, effective)
+ let fee = try! Amount.diff(raw, effective) // TODO: different currencies
let dateString = TalerDater.dateString(from: transaction.timestamp)
VStack() {
diff --git a/TalerWallet1/Views/Transactions/TransactionsListView.swift b/TalerWallet1/Views/Transactions/TransactionsListView.swift
@@ -53,12 +53,12 @@ extension TransactionsListView {
var body: some View {
let transactions = viewModel.transactions!
- List(transactions, id: \.transactionId) { transaction in
- NavigationLink {
- TransactionDetail(transaction: transaction)
- } label: {
- TransactionRow(transaction: transaction)
- }
+ List(transactions, id: \.transactionId) { transaction in
+ NavigationLink {
+ TransactionDetail(transaction: transaction)
+ } label: {
+ TransactionRow(transaction: transaction)
+ }
.swipeActions(edge: .leading, allowsFullSwipe: true) {
Button {
symLog?.log("bookmarked \(transaction.transactionId)")
@@ -75,12 +75,17 @@ extension TransactionsListView {
Label("Delete", systemImage: "trash")
}
}
- }
- .navigationBarTitleDisplayMode(.large) // .inline
- .refreshable {
+ }
+ .navigationBarTitleDisplayMode(.large) // .inline
+ .refreshable {
+ do {
symLog?.log("refreshing")
- try? await reloadAction() // TODO: catch error
+ try await reloadAction()
+ } catch {
+ // TODO: error
+ symLog?.log(error.localizedDescription)
}
+ }
}
}
}
diff --git a/TalerWallet1/Views/Withdraw/WithdrawAcceptView.swift b/TalerWallet1/Views/Withdraw/WithdrawAcceptView.swift
@@ -37,7 +37,7 @@ struct WithdrawAcceptView: View {
case .receivedAmountDetails, .receivedTOS, .receivedTOSAck:
let raw = detailsForAmount.amountRaw
let effective = detailsForAmount.amountEffective
- let fee = try! raw - effective
+ let fee = try! Amount.diff(raw, effective) // TODO: different currencies
Form {
AmountView(title: "Chosen amount to withdraw:",
value: raw.readableDescription, color: Color(UIColor.label))