fix(add): surface search failure with error toast

Catch block previously set hits = [] silently, so a 15s network
timeout looked like "no funds matched". Now an error toast tells
the user it's a network issue, distinct from "no results."

P0 from 2026-05-19 code review.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
徐翔宇 2026-05-19 17:52:33 +08:00
parent a4a747bc77
commit 0d28e9e9d4

View File

@ -136,7 +136,11 @@ struct AddView: View {
do { do {
hits = try await FundClient.shared.search(q) hits = try await FundClient.shared.search(q)
} catch { } catch {
// P0 fix (2026-05-19 review): silent swallow used to make
// a 15s network timeout look like "no funds matched". Surface
// the actual failure so users know it's network, not empty.
hits = [] hits = []
ToastController.shared.error("搜索失败,请检查网络后重试")
} }
} }
} }