taler-android

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

release-error-screen-explains-nothing.diff (3393B)


      1 diff --git a/wallet/src/main/java/net/taler/wallet/backend/WalletResponse.kt b/wallet/src/main/java/net/taler/wallet/backend/WalletResponse.kt
      2 index a73e286c..dc719377 100644
      3 --- a/wallet/src/main/java/net/taler/wallet/backend/WalletResponse.kt
      4 +++ b/wallet/src/main/java/net/taler/wallet/backend/WalletResponse.kt
      5 @@ -78,6 +78,14 @@ data class TalerErrorInfo(
      6      // so they are not re-encoded as -1.
      7      val rawCode: Int = code.code,
      8  ) {
      9 +    /**
     10 +     * What to show a user, which is often nothing: plenty of errors carry
     11 +     * neither a hint nor a message -- 7001 and 7048 among them -- and this is
     12 +     * then empty.  A display site that has a [android.content.Context] should
     13 +     * fall back to the error code; this class has none, and the code's own
     14 +     * name ("WALLET_UNEXPECTED_EXCEPTION") is not something to put in front
     15 +     * of a user.
     16 +     */
     17      val userFacingMsg: String
     18          get() {
     19              return StringBuilder().apply {
     20 @@ -93,7 +101,7 @@ data class TalerErrorInfo(
     21                      hint?.let { append(it) }
     22                      message?.let { append(" ").append(it) }
     23                  }
     24 -            }.toString()
     25 +            }.toString().trim()
     26          }
     27  
     28      fun getStringExtra(key: String): String? =
     29 diff --git a/wallet/src/main/java/net/taler/wallet/compose/ErrorComposable.kt b/wallet/src/main/java/net/taler/wallet/compose/ErrorComposable.kt
     30 index d3a8165f..ddd2d0ed 100644
     31 --- a/wallet/src/main/java/net/taler/wallet/compose/ErrorComposable.kt
     32 +++ b/wallet/src/main/java/net/taler/wallet/compose/ErrorComposable.kt
     33 @@ -116,7 +116,15 @@ fun ErrorComposable(
     34              }
     35          } else {
     36              Text(
     37 -                text = error.userFacingMsg,
     38 +                // Without developer mode this is the whole explanation, and
     39 +                // for an error with neither a hint nor a message it is empty,
     40 +                // which leaves the sheet saying only "Error".  The code is
     41 +                // not an explanation either, but it is something the user can
     42 +                // report.  rawCode rather than code.code: a code newer than
     43 +                // this app's registry is preserved there.
     44 +                text = error.userFacingMsg.ifEmpty {
     45 +                    stringResource(R.string.error_code_only, error.rawCode)
     46 +                },
     47                  fontFamily = FontFamily.Default,
     48                  textAlign = TextAlign.Center,
     49              )
     50 diff --git a/wallet/src/main/res/values/strings.xml b/wallet/src/main/res/values/strings.xml
     51 index 905e4390..b3a63920 100644
     52 --- a/wallet/src/main/res/values/strings.xml
     53 +++ b/wallet/src/main/res/values/strings.xml
     54 @@ -65,6 +65,7 @@ GNU Taler is immune to many types of fraud such as credit card data theft, phish
     55      <string name="enter_uri_label">Taler link</string>
     56      <string name="enter_uri_prefix" translatable="false">taler://</string>
     57      <string name="error">Error</string>
     58 +    <string name="error_code_only">Error code %1$d</string>
     59      <string name="error_export">Export error diagnostics</string>
     60      <string name="wallet_init_error_title">Initialization error</string>
     61      <string name="wallet_init_error_message">An error occurred while starting the wallet. This can happen after an app update or if the wallet data is incompatible. Please retry, and if the problem persists, export the logs and report this issue to the developers.</string>