Handle errors and retries
Guides

Handle errors and retries

This page covers core consumer errors. Consumer Bluetooth has additional error types. Merchant integrations use POS errors and recovery rules.

Handle SDK errors by kind: Android uses WolletteException; iOS uses WolletteError. Message wording can vary by operation, so do not use it for control flow. Also handle coroutine/task cancellation and errors from your own dependencies separately.

FieldMeaning
kindStable code, for example VALIDATION or .validation
messagePublic text for display; do not parse it
statusCodeHTTP status when the failure came from the server
retryableTrue only when the call is marked safe to retry and the failure was a network error, HTTP 429 or HTTP 5xx
cause (Android) / underlyingDescription (iOS)Transport or decoding diagnostic

A handling pattern

try {
    sdk.onboarding.verifyOtp(code, provider)
} catch (e: WolletteException) {
    when (e.kind) {
        WolletteErrorKind.OTP_INVALID -> showWrongCode()
        WolletteErrorKind.OTP_COOLDOWN -> showWaitBeforeResend()
        WolletteErrorKind.UNAUTHORIZED -> showSignIn()
        WolletteErrorKind.WALLET_NOT_READY -> startActivation()
        WolletteErrorKind.DEVICE_COMPROMISED -> showDeviceBlocked()
        else -> if (e.retryable) offerRetry() else showError(e.message)
    }
}

Which calls are safe to retry

Read/reconciliation operations: checkPhone, checkEmail, checkUsername, wallet retrieve, linkedAccounts, reconcileTopUp, transaction list, and profile retrieve.

Not safe to auto-retry: OTP requests and verification, createUser, profile updates, password changes, balance-control updates, topUp, payOut and pay. For these, re-read state before deciding to submit again. awaitTopUpCompletion keeps calling reconcileTopUp and reports a retryable SERVER error after 180 seconds.

A multi-step method can fail during a prerequisite read and propagate retryable=true before its mutation. The mutation request itself remains unsafe to replay automatically. Use the operation-specific state/reconciliation contract; do not turn the flag into a generic financial Retry button.

Codes that change your flow

KindWhat it means for your app
UNAUTHORIZEDThe session is gone or the token is not a consumer token. Sign in again
WALLET_NOT_READYNo BaaS account was returned. Check pending and general activation progress before continuing
CANCELLEDThe user closed the login page or a wallet form. Return to your screen
ONBOARDING_FAILEDA wallet form reported failure. Offer retry
DEVICE_COMPROMISEDStop the flow, show a device error, do not retry login. The SDK attempts cleanup; a storage failure can leave some data undeleted
REGISTRATION_STATERegistration steps out of order. Restart from the OTP request
VALIDATIONCheck input/proof and the operation. It also represents the specific PIS insufficient-funds rejection. Discard the previous consumer UI only when you know the session changed
STORAGEThe device's secure storage is unavailable

The full catalogue with causes is in Errors.

iOS task cancellation

Cancelling the Swift Task that is awaiting login during the browser wait or token exchange throws CancellationError, not .cancelled. Handle both.

Session replacement during a call

If you know the session changed during a call, discard the old consumer UI when it returns VALIDATION. Otherwise check inputs and context first; the error kind alone does not prove a session change. For applySession, malformed JWTs use INVALID_RESPONSE, while disallowed consumer claims use UNAUTHORIZED.

Diagnose the failure before offering Retry

SymptomCheckNext action
VALIDATION before HTTPInputs, developer ID/proof shape and any session changeCorrect configuration/context first; validation alone does not prove sign-out
UNAUTHORIZEDSession owner and token type/environmentReauthenticate or renew the host-managed session
NETWORK on a readretryable, connectivity and current consumer contextOffer an explicit read retry when eligible
Failure after a mutationOperation-specific progress/reconciliation APIRead current state before deciding whether to submit again
Cleanup reports storage failureWhich cleanup steps completedKeep protected UI unavailable; follow incomplete cleanup

For support, collect SDK revision, platform/OS, operation, kind and HTTP status. Never log private keys, tokens, OTPs or signatures. Share transaction identifiers through the approved support channel.

Troubleshoot the first failing checkpoint

FailureCheck and next actionExpected result / escalation
Package cannot resolveCorrect module/version and read permissions; use the documented source path when applicableDependency resolves; otherwise the package owner fixes access
Developer proof rejected before HTTPCheck origin, installed alias/tag, fresh UUID, RSA key and proof shapeLocal validation passes; enrolment/verification still needs Wollette confirmation
Login fails to returnMatch the registered URI, SDK configuration and Android manifest/iOS URL TypesReturn to the active app; otherwise confirm callback registration
Top-up VALIDATION, HTTP 401, safe message Insufficient fundsThe SDK recognised the specific PIS business rejection and skipped refresh/replayDisplay the rejection; do not force sign-in or automatically submit again
Consumer UNAUTHORIZED (normally HTTP 401)Check identity, remaining lifetime, environment and enrolled signing materialSign in/renew through the correct session owner, then explicitly read
Wallet not readyAfter sign-in inspect pendingProgress before general progressResume the saved operation or outstanding activation step
OTP rejected/cooldownUse the typed kind and approved resend intervalUser corrects the code or waits; avoid repeated OTP requests

For iOS consumer payment/Bluetooth work, handle ConsumerPaymentError, BleTransportError, core errors and native cancellation separately. Use the diagnostic template and include only fields actually exposed by that error family. For merchant uncertainty use the POS recovery rules, rather than a generic Retry action.

Diagnostic examples

These are decision examples, not captured live-test results. Use fields actually exposed by the error.

ObservationCheckNext action
VALIDATION occurs before an HTTP attemptLocal inputs, DeveloperId, nonce/signature shape and any known consumer changeCorrect the local setup; a well-shaped proof still needs server verification
An authenticated wallet read returns UNAUTHORIZED with HTTP 401Consumer session ownership, remaining lifetime, token type and environment; enrolled signing material with WolletteHosted sessions use their configured SDK renewal path. For host-managed sessions, obtain a current token and apply it, then explicitly read
A read fails with NETWORK and retryable=trueConnectivity and the current consumer contextOffer a read retry. This flag does not authorise resubmitting a financial mutation

Use the support template if the approved inputs still fail. A real support destination and known proof-verification example remain Wollette requirements.