taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

commit 42d2953cf4789f60609d04557d68bd97b6c1fcae
parent 822890199c836113bffb0e57546447068f229a50
Author: Iván Ávalos <avalos@disroot.org>
Date:   Sat, 24 Jun 2023 23:11:39 -0600

[wallet] Show errorResponse hint in error response when available.

Diffstat:
Mwallet/src/main/java/net/taler/wallet/backend/WalletResponse.kt | 14++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/wallet/src/main/java/net/taler/wallet/backend/WalletResponse.kt b/wallet/src/main/java/net/taler/wallet/backend/WalletResponse.kt @@ -29,6 +29,7 @@ import kotlinx.serialization.json.JsonElement import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonPrimitive import kotlinx.serialization.json.buildJsonObject +import kotlinx.serialization.json.jsonObject import kotlinx.serialization.json.jsonPrimitive @Serializable @@ -75,8 +76,17 @@ data class TalerErrorInfo( val userFacingMsg: String get() { return StringBuilder().apply { - hint?.let { append(it) } - message?.let { append(" ").append(it) } + // If there's a hint in errorResponse, use it. + extra["errorResponse"] + ?.jsonObject + ?.get("hint") + ?.let { + append(it.jsonPrimitive.content) + } ?: { + // Otherwise, use the standard ones. + hint?.let { append(it) } + message?.let { append(" ").append(it) } + } }.toString() }