ErrorCode

Every value SponsorkitError.code can take.

On this page

Type alias in sponsorkit.errors.

from sponsorkit import ErrorCode

Also importable from sponsorkit.errors.

ErrorCode = Literal[
    "invalid_config",
    "disabled",
    "popup_blocked",
    "access_denied",
    "invalid_state",
    "provider_error",
    "invalid_code",
    "cancelled",
    "timeout",
    "network_error",
    "session_invalid",
    "targets_mismatch",
]

Every value SponsorkitError.code can take.

  • invalid_config: no targets, a malformed target, an invalid option (including invalid checkout_url() options), an unknown mock preset, an unwritable storage directory, or (dev-time check) a target that does not exist.
  • disabled: SPONSORKIT_DISABLE is set; raised by sign-in and checkout.
  • popup_blocked: browser SDKs only; never raised by the Python SDK.
  • access_denied / invalid_state / provider_error: sign-in errors delivered by the sign-in page to the loopback callback.
  • invalid_code: the API rejected the code exchange (400 invalid_code: malformed, expired or tampered code, or a verifier mismatch).
  • cancelled: sign-in was cancelled through its cancel event, or the user entered no code at the paste-back prompt. Cancelling the task that awaits asign_in() or aopen_checkout() raises asyncio.CancelledError instead.
  • timeout: sign-in did not complete within sign_in_timeout (300 s by default) or the timeout passed to that call.
  • network_error: sign-in or verify_session() could not reach the API, or it answered 5xx, 429 or something unexpected. SponsorkitError.retry_after carries the API's Retry-After in seconds when it sent one.
  • session_invalid / targets_mismatch: only raised by sponsorkit.server.verify_session().

get_financial_contribution() never raises for network or server problems.

Values#

Value
"invalid_config"
"disabled"
"popup_blocked"
"access_denied"
"invalid_state"
"provider_error"
"invalid_code"
"cancelled"
"timeout"
"network_error"
"session_invalid"
"targets_mismatch"

Used by#