Skip to content

Errors

SdkError is the SDK’s single error type: code: SdkErrorCode, reason: SdkErrorReason, an optional human-readable errorMessage, and an optional providerError for social-provider failures. It conforms to LocalizedError, and its message is automatically redacted — any embedded JWT or Bearer ... token is replaced with [redacted] before it is ever surfaced to your code or a log.

Two delivery paths — know which one you’re handling

Section titled “Two delivery paths — know which one you’re handling”
  • Configuration errors throw synchronously. Constructing an invalid RakomiAuthConfiguration throws an SdkError from the initializer — these are programmer errors and must be caught with ordinary Swift do/catch, not observed on a stream.
  • Every runtime auth error is emitted, never thrown. RakomiAuth’s async sign-in/session methods never throw for an auth-flow failure; they emit AuthState.error(SdkError) on authStateChanges(). getToken() is one exception — it throws when there is no valid session, so a caller reaching for a token gets a normal Swift error at the call site.

The top-level classification. Its wire form (used in logging and cross-platform parity) is the uppercase SCREAMING_SNAKE_CASE shown in the second column.

CaseWire value
refreshFailedREFRESH_FAILED
oauthCallbackErrorOAUTH_CALLBACK_ERROR
tenantSuspendedTENANT_SUSPENDED
csrfMismatchCSRF_MISMATCH
codeExchangeFailedCODE_EXCHANGE_FAILED
signInFailedSIGN_IN_FAILED
invalidConfigINVALID_CONFIG
networkErrorNETWORK_ERROR
providerErrorPROVIDER_ERROR
biometricErrorBIOMETRIC_ERROR
storageErrorSTORAGE_ERROR
rateLimitedRATE_LIMITED
invalidCredentialsINVALID_CREDENTIALS
mfaStepUpRequiredMFA_STEP_UP_REQUIRED
mfaStepUpUnavailableMFA_STEP_UP_UNAVAILABLE
unknownUNKNOWN

A discriminating sub-reason, combined with the code above for the full picture. Its wire form is snake_case.

CaseWire value
oauthUserCancelledoauth_user_cancelled
oauthLockedoauth_locked
oauthStateMismatchoauth_state_mismatch
oauthRedirectMismatchoauth_redirect_mismatch
oauthMissingParamsoauth_missing_params
oauthProviderErroroauth_provider_error
CaseWire value
biometricCancelledbiometric_cancelled
biometricLockoutbiometric_lockout
biometricNotEnrolledbiometric_not_enrolled
biometricUnavailablebiometric_unavailable
CaseWire value
sessionExpiredsession_expired
sessionRevokedsession_revoked
CaseWire value
refreshExpiredrefresh_expired
refreshRevokedrefresh_revoked
refreshNetworkrefresh_network
CaseWire value
mfaStepUpRequiredmfa_step_up_required
mfaStepUpUnavailablemfa_step_up_unavailable
CaseWire value
invalidCredentialsinvalid_credentials
rateLimitedrate_limited
CaseWire value
deviceCodeAuthorizationPendingdevice_code_authorization_pending
deviceCodeSlowDowndevice_code_slow_down
deviceCodeAccessDenieddevice_code_access_denied
deviceCodeExpireddevice_code_expired
CaseWire valueMeaning
dpopProverUnavailabledpop_prover_unavailableThe device could not produce a proof (transient) — the session is kept, no proof-less request was made.
invalidDpopProofinvalid_dpop_proofThe server rejected the proof — the session is cleared; re-authenticate to bind a fresh key.
invalidRefreshTokeninvalid_refresh_tokenThe refresh token itself was rejected — the session is cleared.
CaseWire value
networknetwork
unknownunknown
case .error(let sdkError):
print(sdkError.errorDescription)
// "SdkError(code=SIGN_IN_FAILED, reason=invalid_credentials, message=...)"

errorDescription and redactedMessage never contain a raw JWT or Authorization header value — even one embedded mid-string in a wrapped provider error is scrubbed before it reaches your code.