Reference
Error handling
One enum, DecaneError, with three variants. It is #[non_exhaustive], so keep a wildcard arm.
rust
use decane::{ApiErrorCode, DecaneError};
match decane.verify_email_code(email, code).await {
Ok(session) => { /* signed in */ }
Err(DecaneError::Api { code: ApiErrorCode::InvalidCode, .. }) => { /* ask again */ }
Err(DecaneError::Api { code, status, .. }) => { /* status 0: never reached Decane */ }
Err(err) => return Err(err.into()),
}Variants
Auth { reason, message, source }: the token cannot be trusted.reasonisAuthErrorReason::InvalidToken,MissingUidorProjectMismatch.Api { code, status, message, source }: a backend call failed.statusis the HTTP status, 0 when the request never got a response.Config(String): a missing key or secret, an empty argument, a malformed verification key. Raised before any network call.
Helpers: is_auth(), auth_reason(), api_code(), status().
ApiErrorCode
ApiErrorCode implements Display and FromStr with the wire strings (INVALID_CODE, …), so logs read the same as the Node SDK’s.
| Code | Meaning |
|---|---|
InvalidCode | Email or SMS code wrong or expired |
AuthFailed | Provider token rejected |
InvalidToken | Custom-auth JWT rejected |
NoProvider, AmbiguousProvider, MissingClaim | Custom-auth provider configuration |
InvalidApiKey, AppIdMismatch | Credential problems |
SmsNotConfigured | Phone sign-in on a deployment with no SMS provider |
KingsChatNotConfigured, KingsChatUnavailable | KingsChat setup, or an upstream outage |
InvalidRecord, NotFound, Unauthorized | Record calls |
ServerWalletsDisabled, InvalidIdentifier, WalletExists, WalletFrozen, RetryLater, EnclaveUnavailable | User and wallet creation |
RateLimited | HTTP 429 with no envelope |
Unknown, NetworkError | Unparseable response, or the request never completed (status 0) |
Other(String) | A code this version does not know by name; the wire string is kept |