Errors

Structured error codes and recovery guidance for the React Native SDK.

The React Native SDK does not throw. Every failure is a VoidhashError with a stable, machine-matchable code string, and client methods deliver it as a value instead of rejecting. Each method returns a better-result Result: a success lands on the Ok side, and a failure lands on the Err side with the error attached. The code tells you which operation failed and what to do next. Match on error.code when the recovery differs by cause, and report the full error for everything else.

This example checks the result for one specific code:

const result = await voidhash.client.getProducts();
if (result.isErr() && result.error.code === "FAILED_TO_GET_PRODUCTS") {
  // retry, fall back to cached products, …
}

Hooks surface the same errors through their error field instead of throwing.

Operation codes

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

CodeReturned byRecovery guidance
FAILED_TO_INITIALIZE_VOIDHASH_CLIENTinit()Show a retry screen that calls useVoidhash().retryInit.
FAILED_TO_CAPTURE_STARTUP_EVENTSinit() analytics stepNon-fatal. The SDK logs it as a warning.
FAILED_TO_SETUP_LIFECYCLE_EVENTSinit() lifecycle stepNon-fatal for reads, but automatic lifecycle events are missing.
FAILED_TO_END_VOIDHASH_CLIENTend()Log it and continue teardown.
FAILED_TO_FETCH_SCHEMAinit() on a cold cacheCheck connectivity. The next launch retries.
FAILED_TO_GET_CURRENT_PERSONgetCurrentPerson(), hasPerk()Serve cached state. See Check access.
FAILED_TO_SET_PERSON_ATTRIBUTESsetPersonAttributes()Retry later. Attributes ride the analytics queue.
FAILED_TO_SET_PERSON_ATTRIBUTES_SYNCsetPersonAttributesSync()Retry. Check for read-only mode first (READ_ONLY_PURCHASE_NOT_ALLOWED).
FAILED_TO_RESET_PERSON_CACHEresetCache()Safe to ignore. The cache expires on its own.
FAILED_TO_GET_DISTINCT_IDgetDistinctId()Retry after init completes.
FAILED_TO_IDENTIFYidentify()Retry. An already-identified person surfaces this code too.
FAILED_TO_RESETreset()Retry.
FAILED_TO_SIGN_OUTsignOut()Retry.
FAILED_TO_GET_FEATURE_FLAGSgetFeatureFlags()Fall back to your default values.
FAILED_TO_GET_PRODUCTSgetProducts()Retry, or render the screen without store metadata.
FAILED_TO_PURCHASEpurchase()Reserved for the later commerce launch.
FAILED_TO_RESTORE_PURCHASESrestorePurchases()Prompt the customer to retry.
FAILED_TO_REPORT_TRANSACTIONreportTransaction(...)Supply a valid Apple transaction ID or Google Play purchase token.
FAILED_TO_SYNC_PURCHASESsyncPurchases()Inspect the store error and retry. Captured receipts with delivery failures remain queued.
FAILED_TO_FLUSH_ANALYTICSflush()Nothing to do. Events stay queued and flush later.
FAILED_TO_PRESENT_CODE_REDEMPTION_SHEETiOS redemption sheetiOS only. Verify the offer code configuration.
FAILED_TO_SHOW_MANAGE_SUBSCRIPTIONSiOS manage subscriptionsiOS only. Requires iOS 15 or later.

Client-state codes

These codes describe the state of the client rather than a single operation:

CodeMeaning
VOIDHASH_CLIENT_NOT_INITIALIZEDA method ran before the provider finished init(). Gate calls on useVoidhash().status === "ready".
READ_ONLY_PURCHASE_NOT_ALLOWEDPurchase initiation is unavailable in the observer-only release.
SCHEME_NOT_SETReserved for paywall callback configuration.
UNSUPPORTED_PLATFORMA platform-specific method ran on a platform it does not support, such as an iOS-only call on Android.
UNKNOWNAn unexpected failure. Report the full error.

Purchase availability

purchase() currently returns an Err before the native store is touched. The error carries the code READ_ONLY_PURCHASE_NOT_ALLOWED, which means purchase initiation is unavailable in the observer-only release.

Next steps