RCPurchasesErrorUtils


@interface RCPurchasesErrorUtils : NSObject

Utility class used to construct [NSError] instances.

  • Constructs an NSError with the [RCNetworkError] code and a populated [RCUnderlyingErrorKey] in the [NSError.userInfo] dictionary.

    Note

    This error is used when there is an error performing network request returns an error or when there is an [NSJSONSerialization] error.

    Declaration

    Objective-C

    + (nonnull NSError *)networkErrorWithUnderlyingError:
        (nonnull NSError *)underlyingError;

    Parameters

    underlyingError

    The value of the [NSUnderlyingErrorKey] key.

  • Maps an RCBackendError code to a RCPurchasesErrorCode code. Constructs an NSError with the mapped code and adds a [RCUnderlyingErrorKey] in the [NSError.userInfo] dictionary. The backend error code will be mapped using [RCPurchasesErrorCodeFromRCBackendErrorCode].

    Note

    This error is used when an network request returns an error. The backend error returned is wrapped in this internal error code.

    Declaration

    Objective-C

    + (nonnull NSError *)
        backendErrorWithBackendCode:(nullable NSNumber *)backendCode
                     backendMessage:(nullable NSString *)backendMessage;

    Parameters

    backendCode

    The value of the error key.

    backendMessage

    The value of the [NSUnderlyingErrorKey] key.

  • Maps an RCBackendError code to a [RCPurchasesErrorCode] code. Constructs an NSError with the mapped code and adds a [RCUnderlyingErrorKey] in the [NSError.userInfo] dictionary. The backend error code will be mapped using [RCPurchasesErrorCodeFromRCBackendErrorCode].

    Note

    This error is used when an network request returns an error. The backend error returned is wrapped in this internal error code.

    Declaration

    Objective-C

    + (nonnull NSError *)
        backendErrorWithBackendCode:(nullable NSNumber *)backendCode
                     backendMessage:(nullable NSString *)backendMessage
                         finishable:(BOOL)finishable;

    Parameters

    backendCode

    The value of the error key.

    backendMessage

    The value of the [NSUnderlyingErrorKey] key.

    finishable

    Will be added to the UserInfo dictionary under the [RCFinishableKey] to indicate if the transaction should be finished after this error.

  • Constructs an NSError with the [RCUnexpectedBackendResponseError] code.

    Note

    This error is used when an network request returns an unexpected response.

    Declaration

    Objective-C

    + (nonnull NSError *)unexpectedBackendResponseError;
  • Constructs an NSError with the [RCMissingReceiptFileError] code.

    Note

    This error is used when the receipt is missing in the device. This can happen if the user is in sandbox or if there are no previous purchases.

    Declaration

    Objective-C

    + (nonnull NSError *)missingReceiptFileError;
  • Constructs an NSError with the [RCInvalidAppUserIdError] code.

    Note

    This error is used when the appUserID can’t be found in user defaults. This can happen if user defaults are removed manually or if the OS deletes entries when running out of space.

    Declaration

    Objective-C

    + (nonnull NSError *)missingAppUserIDError;
  • Constructs an NSError with the [RCLogOutAnonymousUserError] code.

    Note

    This error is used when logOut is called but the current user is anonymous, as noted by RCPurchaserInfo’s isAnonymous property.

    Declaration

    Objective-C

    + (nonnull NSError *)logOutAnonymousUserError;
  • Constructs an NSError with the [RCPaymentPendingError] code.

    Note

    This error is used during an “ask to buy” flow for a payment. The completion block of the purchasing function will get this error to indicate the guardian has to complete the purchase.

    Declaration

    Objective-C

    + (nonnull NSError *)paymentDeferredError;
  • Constructs an NSError with the [RCUnknownError] code.

    Declaration

    Objective-C

    + (nonnull NSError *)unknownError;
  • Maps an SKErrorCode code to a RCPurchasesErrorCode code. Constructs an NSError with the mapped code and adds a [RCUnderlyingErrorKey] in the NSError.userInfo dictionary. The SKErrorCode code will be mapped using [RCPurchasesErrorCodeFromSKError].

    Declaration

    Objective-C

    + (nonnull NSError *)purchasesErrorWithSKError:(nonnull NSError *)skError;

    Parameters

    skError

    The originating [SKError].