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.
| Code | Thrown by | Recovery guidance |
|---|---|---|
CONFIGURATION_MISSING | Any call before init succeeds | Await waitForInitialization(), or retry later. |
FAILED_TO_GET_CURRENT_PERSON | getCurrentPerson() | Serve cached state. See Check access. |
FAILED_TO_SET_PERSON_ATTRIBUTES | setPersonAttributes() | Retry later. |
FAILED_TO_IDENTIFY | identify() | Retry. An already-identified person surfaces this code too. |
FAILED_TO_GET_FEATURE_FLAGS | getFeatureFlags() | Fall back to your default values. |
FAILED_TO_GET_PRODUCTS | getProducts() | Retry, or render the screen without store metadata. |
FAILED_TO_PURCHASE | purchase(product:) | Reserved for the later commerce launch. |
INVALID_TRANSACTION | reportTransaction(...) | Supply a non-empty original App Store transaction ID. |
FAILED_TO_RESTORE_PURCHASES | restorePurchases() | Prompt the customer to retry. |
Passing an unverified StoreKit result to reportTransaction(...) throws its verification error.
Purchase availability
purchase(product:) currently throws before StoreKit is touched. The error carries the code
READ_ONLY_PURCHASE_NOT_ALLOWED, which means purchase initiation is unavailable in the
observer-only release.