From 69762133feea06b7376a5c8bfec8369e7c4a4bce Mon Sep 17 00:00:00 2001 From: Terry Yiu Date: Thu, 10 Sep 2026 12:01:15 +0300 Subject: [PATCH] Show a fixed, generic message for fetch errors instead of e.message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Exceptions from the HTTP client or JSON parsing can carry verbose, technical text (full response bodies, stack traces) — not meaningful to a user seeing it as a red error banner. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01FXcrACM5sok3M1KQJ8kByy --- .../kotlin/xyz/tyiu/satsprice/ui/PriceViewModel.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/shared/src/commonMain/kotlin/xyz/tyiu/satsprice/ui/PriceViewModel.kt b/shared/src/commonMain/kotlin/xyz/tyiu/satsprice/ui/PriceViewModel.kt index eda76ce..caa605d 100644 --- a/shared/src/commonMain/kotlin/xyz/tyiu/satsprice/ui/PriceViewModel.kt +++ b/shared/src/commonMain/kotlin/xyz/tyiu/satsprice/ui/PriceViewModel.kt @@ -169,11 +169,14 @@ class PriceViewModel( newRates, ) } - } catch (e: Exception) { - // Not localized: this shared ViewModel has no platform Context to resolve a moko-resources - // string on Android, and no locale-aware synchronous resolution path that works everywhere. + } catch (_: Exception) { + // A fixed, generic message rather than e.message: exceptions from the HTTP client + // or JSON parsing can carry verbose, technical text (full response bodies, stack + // traces) that isn't meaningful to a user. Not localized: this shared ViewModel has + // no platform Context to resolve a moko-resources string on Android, and no + // locale-aware synchronous resolution path that works everywhere. _uiState.update { - it.copy(isLoading = false, errorMessage = e.message ?: "Could not fetch exchange rates") + it.copy(isLoading = false, errorMessage = "Could not fetch exchange rates") } } }