Errors

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

Every failure raised by the SDK is a VoidhashError with a stable, machine-matchable code, delivered on the Err channel of a better-result Result. Client methods never reject — match on error.code when recovery differs, and report the full error for everything else.

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.

CodeThrown byRecovery guidance
FAILED_TO_INITIALIZE_VOIDHASH_CLIENTinit()Surface a retry screen via useVoidhash().retryInit.
FAILED_TO_CAPTURE_STARTUP_EVENTSinit() analytics stepNon-fatal; logged as a warning.
FAILED_TO_SETUP_LIFECYCLE_EVENTSinit() lifecycle stepNon-fatal for reads; automatic lifecycle events are missing.
FAILED_TO_END_VOIDHASH_CLIENTend()Log 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 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 defaults.
FAILED_TO_GET_PRODUCTSgetProducts()Retry or render without store metadata.
FAILED_TO_PURCHASEpurchase()Reserved for the later commerce launch.
FAILED_TO_RESTORE_PURCHASESrestorePurchases()Prompt the customer to retry.
FAILED_TO_FLUSH_ANALYTICSflush()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+.

Client-state codes

CodeMeaning
VOIDHASH_CLIENT_NOT_INITIALIZEDA method ran before the provider finished init(). Gate 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 elsewhere (e.g. an iOS-only call on Android).
UNKNOWNAn unexpected failure. Report the full error.

Purchase availability

purchase() currently returns an Err carrying READ_ONLY_PURCHASE_NOT_ALLOWED before the native store is touched.

Next steps