Error Handling
This guide covers error handling patterns for the Privacy Boost React Native SDK. For the cross-platform error code reference, see Error Handling Concepts.SdkError
All SDK errors are instances ofSdkError, a tagged union where each variant
is a constructable class exported under SdkError.*. Use .instanceOf(err)
to check the variant, or inspect err.tag (values come from the
SdkError_Tags enum).
| Tag | Data | Meaning |
|---|---|---|
NotConnected | — | Wallet not connected |
NotAuthenticated | — | SDK is not logged in |
NetworkError | { message } | Transport-level failure |
WalletError | { message } | Wallet delegate returned an error |
SignatureRejected | — | User cancelled a wallet signature |
InsufficientBalance | — | Not enough funds to cover amount + fees |
InvalidAddress | — | Address failed validation |
InvalidAmount | — | Amount couldn’t be parsed or is out of range |
SerializationError | { message } | Encoding/decoding failure |
AuthServerError | { message } | Auth backend rejected the request |
ShieldError | { message } | Shield operation failed |
TransferError | { message } | Transfer operation failed |
NoteError | { message } | Shielded-note bookkeeping failed |
MerkleError | { message } | Merkle-tree proof construction failed |
ApiError | { code, message, retryable } | Indexer/prover returned an error |
RateLimited | { retryAfterMs } | Server requested backoff |
Forbidden | { message } | Authenticated but not authorized |
ResourceNotFound | — | Requested entity doesn’t exist |
InternalError | { message } | Unclassified failure |
Basic Error Handling
PreferinstanceOf over manual tag checks — it’s safer against variant
renames:
Accessing variant data: errors expose their payload under.inner(e.g.error.inner.message,error.inner.retryAfterMs). The cast toanyis needed because the generated union widens the type.
Switch on error.tag
If you prefer a single switch block over cascading ifs: