Solved

Proper Error Handling

  • 17 April 2024
  • 1 reply
  • 24 views

Badge

I’m working on the best way to handle errors in my app, referencing the revenuecat error documentation.

It seems to me that there are broadly four classes of error:

  • `PurchaseCancelledError` - which is simple enough to handle in the UI
  • `NetworkError` - in which a purchase definitely didn’t go through, and I can give my users a chance to retry the purchase
  • Errors related to my code and configuration - in this case, I should display an error message, send an alert to our error logging system, and not allow the user to proceed. 
  • And `StoreProblemError`

The last category of error I find puzzling - `StoreProblemError`. The documentation says that “If everything was working while testing, you shouldn't have to do anything to handle this error in production. RevenueCat will automatically retry any purchase failures so no data is lost.” 

So if I’m reading this correctly, the user will not have an active subscription made immediately, but they will have a subscription made eventually because the revenuecat backend will keep on retrying until the purchase succeeds. So my current strategy for handling this is:

  • Display an error screen to the user and do not  let them retry the purchase
  • Display a message saying that their purchase will go through and we will email them when their subscription is active

This seems like a reasonable thing to do based on my reading of the documents but I wanted to check and see if this is correct.

I’m further confused because in Sandbox testing `StoreProblemError` is the error thrown when I try to make a purchase with the Google Play store using the testing card that always fails. I’m concerned this means that an incorrect or expired credit card will also throw a `StoreProblemError`, in which case they will get the error message that their purchase will eventually go through and this is incorrect. 

Please help me think through this! Thanks.

 

icon

Best answer by jeffrey_bunn 19 April 2024, 19:50

View original

This post has been closed for comments

1 reply

Badge +2

Hi @jacob-lyles, thanks for reaching out. Good questions! 

Both the App Store and Google Play won’t allow a subscription to be purchased more than once. In the case of a `StoreProblemError`, you may want to show a loading and/or error UI to the user, but I would not recommend blocking them from retrying the purchase. Please note that this is not the case for a consumable, so if you’re offering consumables, you may want to think about a blocking UI flow.

This applies to your second question as well. It’s possible that you might receive a `StoreProblemError` in the case of an incorrect/expired credit card from Google Play, but this won’t always be the case. It all depends on what happens outside of RevenueCat in the platform’s purchase flow. As with the above, if you’re providing subscriptions, I wouldn’t recommend implementing a blocking flow, as the platform won’t allow them to subscribe more than once.

I hope this helps!