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:(NSNumber *_Nullable)backendCode
                     backendMessage:(NSString *_Nullable)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:(NSNumber *_Nullable)backendCode
                     backendMessage:(NSString *_Nullable)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;
  • 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].