Skip to main content

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 of SdkError, 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).
Available variants:

Basic Error Handling

Prefer instanceOf 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 to any is needed because the generated union widens the type.

Switch on error.tag

If you prefer a single switch block over cascading ifs:

Retry with Exponential Backoff

User-Friendly Error Messages

Categorizing Errors

Best Practices

1. Always handle SignatureRejected silently

When a user cancels a wallet signature, don’t show an error:

2. Log the full error for debugging

3. Use categories for UI decisions

Next Steps