DecaneDocs
ReferenceError handling
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 response

DecaneAuthError

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

CodeMeaning
INVALID_CODEEmail or SMS code wrong or expired
AUTH_FAILEDProvider token rejected
INVALID_TOKENCustom-auth JWT rejected
NO_PROVIDER, AMBIGUOUS_PROVIDER, MISSING_CLAIMCustom-auth provider configuration
INVALID_API_KEY, APP_ID_MISMATCHCredential problems
SMS_NOT_CONFIGUREDPhone sign-in on a deployment with no SMS provider
KINGSCHAT_NOT_CONFIGURED, KINGSCHAT_UNAVAILABLEKingsChat setup, or an upstream outage
INVALID_RECORD, NOT_FOUND, UNAUTHORIZEDRecord calls
SERVER_WALLETS_DISABLED, INVALID_IDENTIFIER, WALLET_EXISTS, WALLET_FROZEN, RETRY_LATER, ENCLAVE_UNAVAILABLEUser and wallet creation
RATE_LIMITEDHTTP 429
UNKNOWN, NETWORK_ERRORUnparseable response, or the request never completed (status 0)