Show generic error message for custom purchase logic errors#3130
Show generic error message for custom purchase logic errors#3130
Conversation
...enuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/TestData.kt
Outdated
Show resolved
Hide resolved
tonidero
left a comment
There was a problem hiding this comment.
I'm usnure if we should do this since it's a bit of a behavior breaking change, and also limits some functionality....Wdyt?
| <string name="no_browser_cannot_open_link">No browser installed. Link could not be opened.</string> | ||
| <string name="cannot_open_link">Link invalid. Could not be opened.</string> | ||
| <string name="external_purchase_error">An error occurred during the purchase. Please try again.</string> | ||
| <string name="external_restore_error">An error occurred while restoring purchases. Please try again.</string> |
There was a problem hiding this comment.
Hmm we might need to localize this in all languages our paywalls are supported I think? This also applies to the strings above TBH :/
| val state: StateFlow<PaywallState> | ||
| val resourceProvider: ResourceProvider | ||
| val actionInProgress: State<Boolean> | ||
| val actionError: State<PurchasesError?> |
There was a problem hiding this comment.
I believe the previous actionError now becomes unused? If so we should remove it.
| } | ||
| is PurchaseLogicResult.Error -> { | ||
| result.errorDetails?.let { _actionError.value = it } | ||
| _actionErrorMessage.value = resourceProvider.getString(R.string.external_restore_error) |
There was a problem hiding this comment.
Hmm I'm a bit unsure... So a developer can use this to customize the error message displayed right? (not the main intent for this, but still it's possible. The developer needs to create a PurchasesError anyway where they can put their error message. I guess I would only use this generic error message in case the developer didn't provide one?
Otherwise this could also be considered a behavior breaking change.
…essage was returned
5d524d7 to
0a94bc2
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| ErrorDialog( | ||
| dismissRequest = viewModel::clearActionError, | ||
| error = it.message, | ||
| error = error.underlyingErrorMessage ?: error.message, |
There was a problem hiding this comment.
RevenueCat errors show technical details instead of user message
Medium Severity
The display logic was changed from error.message to error.underlyingErrorMessage ?: error.message. For PurchasesError, message is the user-facing text from the error code (e.g. "Error performing request."), while underlyingErrorMessage holds technical details (e.g. exception messages). RevenueCat errors from the restore/purchase catch blocks now prefer underlyingErrorMessage, so users may see raw technical text instead of the intended user-friendly message.


Updates custom PurchaseLogic handling to display a generic error message as a fallback in case no error message is returned by the custom PurchaseLogic.
Related iOS PR: RevenueCat/purchases-ios#6334
Related hybrid-common PR: TODO