Reference
Error handling
Three failure domains, three classes, all subclasses of DecaneError.
python
from decane import DecaneApiError, DecaneAuthError, DecaneConfigError
try:
session = decane.verify_email_code(email, code)
except DecaneApiError as err:
if err.code == "INVALID_CODE":
... # ask for the code again
err.status # HTTP status; 0 when the request never got a responseDecaneAuthError
The token cannot be trusted. err.reason is "invalid_token" (bad signature, malformed or expired), "missing_uid" or "project_mismatch".
DecaneConfigError
A mistake in how the client was set up, raised before any network call: a sign-in call without an API key, a by-user-id call without the project secret, a verification key that is not a P-256 public key. A blank required argument (an empty email, token or user id) is a plain ValueError.
DecaneApiError codes
| Code | Meaning |
|---|---|
INVALID_CODE | Email or SMS code wrong or expired |
AUTH_FAILED | Provider token rejected |
INVALID_TOKEN | Custom-auth JWT rejected |
NO_PROVIDER, AMBIGUOUS_PROVIDER, MISSING_CLAIM | Custom-auth provider configuration |
INVALID_API_KEY, APP_ID_MISMATCH | Credential problems |
SMS_NOT_CONFIGURED | Phone sign-in on a deployment with no SMS provider |
KINGSCHAT_NOT_CONFIGURED, KINGSCHAT_UNAVAILABLE | KingsChat setup, or an upstream outage |
INVALID_RECORD, NOT_FOUND, UNAUTHORIZED | Record calls |
SERVER_WALLETS_DISABLED, INVALID_IDENTIFIER, WALLET_EXISTS, WALLET_FROZEN, RETRY_LATER, ENCLAVE_UNAVAILABLE | User and wallet creation |
RATE_LIMITED | HTTP 429 |
UNKNOWN, NETWORK_ERROR | Unparseable response, or the request never completed (status 0) |