Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add root error info to public error #4680

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

tonidero
Copy link
Contributor

@tonidero tonidero commented Jan 17, 2025

Description

This is a possible approach to add root error info to public errors exposed by the SDK. Many times, we have nested errors, which makes discoverability of the root error difficult. This also hides actual StoreKit errors from being easily accessible, which some devs have asked about.

This PR adds a new property to the userInfo of the public error exposed by the SDK including relevant information about the root error. If the root error is a type of StoreKitError, we add some additional information related to that.

For example, when simulating an error getting products during the getOfferings call using StoreKit, a new property in userInfo rc_root_error will be added with the following structure:

{
    code = 4;
    domain = "StoreKit.StoreKitError";
    localizedDescription = "Item Unavailable";
    storeKitError =     {
        description = "not_available_in_storefront";
    };
}

@tonidero tonidero requested a review from a team January 17, 2025 16:31
@tonidero
Copy link
Contributor Author

I want to test this more and add some tests next week, but I wanted to get some feedback, specially from iOS folks, to make sure this makes sense and if there are other ideas to expose the root StoreKit error if any to developers 🙏

@@ -39,7 +40,29 @@ extension PurchasesError {
/// let errorCode = error as? ErrorCode
/// ```
var asPublicError: PublicError {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main concern with this approach is whether we only expose PublicError everywhere and/or if we use this method somewhere else... Need to research it a bit more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant