VoidhashDocs
DocumentationAPI reference
Dashboard
Get started
Introduction
Quickstart
Setup
Setup overview
Create a project
Products and perks
Paywall locations
CLI
Paywall components
Components
Develop a component
Editor panels
Component definition
Publishing
Installing and capabilities
SDKs
Swift
Kotlin
React Native
Web
Store setup
Connect the App Store
Connect Google Play
Connect Stripe
Record payments from other sources
API libraries
Node.js
PHP
Rust
Go
Resources
MCP server
Ad measurement
Meta ads
Migrate in observer mode
Delete a person's data
Swift SDK
Swift quickstart
Display a paywall
Make and restore purchases
Check access
Identify customers
Evaluate feature flags
Capture analytics
Track screens
Development purchase mode
Errors

Errors

Structured error codes and recovery guidance for the Swift SDK.

When an SDK call fails, it throws. Every error the SDK throws is a typed error that carries a code string, and its string form is "CODE: message". The code tells you which operation failed and what to do next. Match on code when the recovery differs by cause, and report the full error for everything else.

This example handles one specific code and lets every other error propagate:

do {
    let products = try await voidhash.getProducts()
} catch let error as VoidhashStoreError where error.code == "FAILED_TO_GET_PRODUCTS" {
    // retry, fall back to cached products, …
}

Operation codes

These codes name the client operation that failed. The message text is informational. Never match on it.

CodeThrown byRecovery guidance
AUTHENTICATION_FAILEDgetCurrentPerson(), getFeatureFlags()Check the publishable key. Thrown once, only when nothing is cached.
CONFIGURATION_MISSINGEmbedded calls on a disabled or replaced clientCall the client that replaced it.
FAILED_TO_GET_PRODUCTSgetProducts()Retry, or render the screen without store metadata.
FAILED_TO_RESTORE_PURCHASESrestorePurchases()The App Store could not be reached. Prompt the customer to retry.
FAILED_TO_SHOW_MANAGE_SUBSCRIPTIONSshowManageSubscriptions()Link to the App Store subscription settings instead.
INVALID_ARGUMENTidentify()Pass an ID Voidhash accepts. The current identity is unchanged.
INVALID_ARGUMENTsetPersonAttributes()Pass only strings, numbers, booleans, or nil. Nothing is saved.
INVALID_TRANSACTIONreportTransaction(...)Supply a non-empty original App Store transaction ID.
RECONCILE_TRANSACTIONS_FAILEDrestorePurchases()Prompt the customer to retry.
USER_CANCELLEDrestorePurchases()The customer dismissed the App Store sign-in. Do nothing.

StoreKit errors never reach your app directly: the SDK wraps them in these codes and keeps StoreKit's description in the message. Passing an unverified StoreKit result to reportTransaction(...) throws its verification error.

identify() and setPersonAttributes() do not throw for network failures or a rejected publishable key: the SDK saves the write and sends it later. They throw a VoidhashApiError only when Voidhash rejects the write for good, and a rejected identify() restores the previous identity. An anonymous ID that already belongs to a different account is not an error: identify() signs the customer in without that ID's history and reports the PERSON_WRITE_REJECTED diagnostic. When Voidhash rejects a write the SDK had saved for later, it drops it and reports the same diagnostic.

Purchase codes

purchase(product:) throws when the purchase did not go through. Cancellation and pending approval are expected outcomes, so match them separately from real failures.

CodeMeaning
USER_CANCELLEDThe customer dismissed the App Store sheet. Do nothing.
PURCHASE_PENDINGThe purchase awaits approval, such as Ask to Buy. The SDK syncs it once it clears, and access arrives then.
INVALID_PRODUCT_IDThe App Store did not return the product. Check the product mapping in Studio and the App Store Connect setup.
OFFER_UNAVAILABLEThe promotional offer passed as offerId cannot be applied, for example because the customer is not eligible. Nothing was bought; offer the regular product instead.
TRANSACTION_VERIFICATION_FAILEDStoreKit could not verify the transaction. Report the full error.
PURCHASE_FAILEDStoreKit failed the purchase. The message carries StoreKit's description. Let the customer try again.
READ_ONLY_PURCHASE_NOT_ALLOWEDThe SDK runs in observer mode, which never starts a purchase. Buy through your other billing SDK, or see Observer mode.

A purchase started from a paywall reports the same failures through onWarning and shows them on the paywall. A cancelled purchase is not reported.

Next steps

  • Check access
  • Swift SDK reference
PreviousDevelopment purchase modeNextKotlin SDK

On this page

Operation codesPurchase codesNext steps