rc-error-handling — скилл для Claude Code: ошибки RevenueCat Android
Разбирает ошибки RevenueCat Android SDK: какой код что значит и что показать пользователю. Пригодится, когда платёжный флоу ломается на проде.
npx skills add RevenueCat/ai-toolkit --skill rc-error-handling -a claude-codeЧто делает rc-error-handling
Скилл описывает работу с PurchasesError вместо ручного перебора BillingResponseCode из Google Play Billing. Внутри — разбор PurchasesErrorCode, таблица кодов с рекомендованной реакцией интерфейса и готовые шаблоны catch-блоков на Kotlin.
Главное правило: awaitPurchase() бросает PurchasesTransactionException с флагом userCancelled, а остальные вызовы (awaitOfferings, awaitGetProducts, awaitCustomerInfo, awaitRestore) — PurchasesException. Отмену пользователем проверяют первой и молча выходят, дальше ветвление по error.code. Строку error.message отправляют в логи, а не в UI: для интерфейса держат одну функцию-маппер.
SDK сам повторяет временные сбои биллинга и сети, поэтому до вас доходят только ошибки с исчерпанным бюджетом ретраев. Свой backoff-цикл вокруг вызовов добавлять не нужно — это сломает задуманное поведение. Единственный ретрай, который имеет смысл, — кнопка «Try Again» по нажатию пользователя.
Какие задачи решает
- различить отмену покупки пользователем и настоящую ошибку
- показать понятный текст вместо технической строки из SDK
- обработать зависшую покупку в статусе pending
- подтянуть актуальные entitlements, если товар уже куплен
- пережить потерю сети при загрузке офферов
Примеры запросов агенту
- Разбери обработку ошибок в этом вызове awaitPurchase по скиллу rc-error-handling
- Проверь, что я сначала смотрю userCancelled, а потом error.code
- Напиши userFacingMessage для PurchasesErrorCode по таблице из скилла
Как установить rc-error-handling
1Через Skills CLI (Vercel)
npx skills add RevenueCat/ai-toolkit --skill rc-error-handling -a claude-code2Вручную: положить файлы
~/.claude/skills/rc-error-handling/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/rc-error-handling/
1Через Skills CLI (Vercel)
npx skills add RevenueCat/ai-toolkit --skill rc-error-handling -a codex2Вручную: положить файлы
.agents/skills/rc-error-handling/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add RevenueCat/ai-toolkit --skill rc-error-handling -a cursor2Вручную: положить файлы
.cursor/skills/rc-error-handling/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install RevenueCat/ai-toolkit rc-error-handling2Вручную: положить файлы
.github/skills/rc-error-handling/SKILL.md1Через Skills CLI (Vercel)
npx skills add RevenueCat/ai-toolkit --skill rc-error-handling -a gemini-cli2Командой платформы
gemini skills install https://github.com/RevenueCat/ai-toolkit --path revenuecat-play-billing/skills/rc-error-handlingВручную: положить файлы
.devin/skills/rc-error-handling/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add RevenueCat/ai-toolkit --skill rc-error-handling -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о rc-error-handling
Как установить rc-error-handling в Claude?
Выполните npx skills add RevenueCat/ai-toolkit --skill rc-error-handling -a claude-code. После этого скилл окажется в ~/.claude/skills/rc-error-handling/SKILL.md.
Что делает rc-error-handling?
Подсказывает агенту, как обрабатывать ошибки RevenueCat Android SDK: какой тип исключения ловить, как ветвить по PurchasesErrorCode и какой текст показать пользователю.
Нужно ли писать свой retry-цикл вокруг вызовов SDK?
Нет. SDK уже повторяет временные сбои биллинга и сети, и любая дошедшая до вас ошибка означает, что бюджет ретраев исчерпан. Оставьте только повтор по кнопке от пользователя.
Исходный текст
SKILL.md · MIT
---
name: rc-error-handling
description: 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.
license: Apache-2.0; see LICENSE
metadata:
author: RevenueCat
source: revenuecat-handbook chapter 8
keywords:
- android
- revenuecat
- error-handling
- purchases-error
- purchases-error-code
- purchases-transaction-exception
---
# 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`.
```kotlin
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 | Show an explanatory message. |
| `IneligibleError` | User not eligible for the offer | Show the base plan instead. |
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`.
```kotlin
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.
```kotlin
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.
```kotlin
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.ProductAlreadyPurchasedError ->
"You already have this subscription."
PurchasesErrorCode.PaymentPendingError ->
"Your payment is being processed. We'll notify you when it completes."
else -> "Something went wrong. Please try again."
}
```
## Checklist
- You picked `PurchasesTransactionException` for `awaitPurchase` and `PurchasesException` elsewhere.
- You checked `userCancelled` before any branching on `error.code`.
- You handled `PaymentPendingError`, `ProductAlreadyPurchasedError`, and `NetworkError` with their specific flows.
- You logged `error.message` and showed a mapped string from `userFacingMessage` to the user.
- You did not add retry loops around SDK calls. Retries are user initiated only.
## References
- [Full chapter](https://www.revenuecat.com/guides/revenuecat-android-sdk/error-handling)
© RevenueCat · MIT · RevenueCat/ai-toolkit