Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

rc-error-handling

БесплатноБез исполняемых скриптовНе проверен

Use this skill when handling errors from the RevenueCat Android SDK. Covers PurchasesError, the PurchasesErrorCode enum, the userCancelled flag on…

RevenueCatот RevenueCat★ 80 звёзд на GitHub

Об этом скилле

Error Handling

Phase 1: Understand

With raw Google Play Billing you enumerate every BillingResponseCode, split them into retriable and non retriable groups, and build backoff retry logic. RevenueCat collapses this into a single type you deal with: PurchasesError.

public class PurchasesError(
    val code: PurchasesErrorCode,
    val underlyingErrorMessage: String? = null,
) {
    val message: String // technical description, for logs
}

Key facts you rely on:

  • PurchasesErrorCode is a cross platform enum with stable, readable codes.
  • error.message is a technical string. It belongs in logs, not in the UI.
  • awaitPurchase() throws PurchasesTransactionException, which adds a userCancelled: Boolean flag.
  • Every other await* call (awaitOfferings, awaitGetProducts, awaitCustomerInfo, awaitRestore) throws PurchasesException.
  • The SDK already retries transient billing and network failures internally. Any error that reaches you has exhausted the SDK retry budget. You do not add your own backoff loop. The only retry you implement is a user triggered "Try Again" button.

Phase 2: Plan

Before writing a catch block, decide three things:

  1. Which await* call are you wrapping? That picks the exception type.
  2. Which codes have specific handling? Everything else falls into a generic branch.
  3. What user facing string does each handled code map to?

Use this table to categorize PurchasesErrorCode values and pick the UX response.

Code Meaning Handling
PurchaseCancelledError User backed out of the flow Do nothing. userCancelled is also true.
ProductAlreadyPurchasedError Product already active for the user Refresh CustomerInfo and check entitlements.
PaymentPendingError Purchase entered pending state Show a pending message. Wait for UpdatedCustomerInfoListener.
NetworkError Request failed due to connectivity Prompt the user to retry.
StoreProblemError Google Play issue Prompt to retry or update Play Store.
PurchaseNotAllowedError Device or account cannot purchase. Since SDK 11.0.0 this includes a Play Store the system blocks (for example an OEM kids mode), which 10.x reported as StoreProblemError. Show an explanatory message. Purchases.awaitCanMakePayments(context) returns false on such a device, so you can hide purchase entry points up front.
ProductNotAvailableForPurchaseError Play reports the product unavailable for this user or region Hide it and refetch offerings.

IneligibleError is App Store only: it comes from a backend promotional offer code, not from Google Play. On Android, Play simply omits ineligible offers from subscriptionOptions.

Exception type decision:

Call Exception to catch userCancelled available?
awaitPurchase() PurchasesTransactionException Yes
awaitRestore() PurchasesException No
awaitOfferings() PurchasesException No
awaitGetProducts() PurchasesException No
awaitCustomerInfo() PurchasesException No

Phase 3: Execute

Purchase errors

Check userCancelled first and return silently. Then branch on error.code.

try {
    val result = Purchases.sharedInstance.awaitPurchase(params)
    handleSuccess(result.customerInfo)
} catch (e: PurchasesTransactionException) {
    if (e.userCancelled) return
    when (e.error.code) {
        PurchasesErrorCode.PaymentPendingError -> showPendingMessage()
        PurchasesErrorCode.ProductAlreadyPurchasedError -> {
            val info = Purchases.sharedInstance.awaitCustomerInfo()
            handleSuccess(info)
        }
        PurchasesErrorCode.NetworkError -> showRetryDialog()
        else -> showGenericError(userFacingMessage(e.error))
    }
}

Non purchase errors

Catch PurchasesException and branch on the code. Use offline or cached fallbacks where you have them.

try {
    val offerings = Purchases.sharedInstance.awaitOfferings()
    displayOfferings(offerings)
} catch (e: PurchasesException) {
    when (e.error.code) {
        PurchasesErrorCode.NetworkError -> showOfflineFallback()
        else -> logError(e.error)
    }
}

Map codes to user facing strings

Keep a single mapping function. Never pass e.error.message to the UI.

fun userFacingMessage(error: PurchasesError): String = when (error.code) {
    PurchasesErrorCode.PurchaseCancelledError -> ""
    PurchasesErrorCode.NetworkError ->
        "Please check your internet connection and try again."
    PurchasesErrorCode.StoreProblemError ->
        "There was a problem with Google Play. Please try again."
    PurchasesErrorCode.PurchaseNotAllowedError ->
        "Purchases are not available on this device or account."
    PurchasesErrorCode.ProductAlreadyPurchasedError ->
        "You already have this subscription."
    PurchasesErrorCode.PaymentPendingError ->
        "Your payment is being
Полный SKILL.md на GitHub

Установить rc-error-handling в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл rc-error-handling?

Use this skill when handling errors from the RevenueCat Android SDK. Covers PurchasesError, the PurchasesErrorCode enum, the userCancelled flag on PurchasesTransactionException, and the recommended UI response per code.

Как установить скилл rc-error-handling?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл rc-error-handling запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить rc-error-handling с