ErrorCode

A stable, machine-readable error code.

On this page

A stable, machine-readable error code.

ErrorCode::as_str returns the wire spelling ("invalid_config", ...), which is identical in every Sponsorkit SDK.

use sponsorkit::ErrorCode;

#[non_exhaustive]
pub enum ErrorCode {
    InvalidConfig,
    Disabled,
    PopupBlocked,
    AccessDenied,
    InvalidState,
    ProviderError,
    InvalidCode,
    Cancelled,
    Timeout,
    NetworkError,
    SessionInvalid,
    TargetsMismatch,
}

Non-exhaustive

This enum is #[non_exhaustive]: new variants may be added in a minor release, so a match on it needs a wildcard (_) arm.

Variants#

VariantWire valueMeaning
InvalidConfiginvalid_configMissing or invalid configuration: no targets, a malformed target, an unknown mock preset, invalid checkout options, (dev-time check) a target that does not exist, or a local environment the SDK cannot work in (an unwritable storage directory, no secure random source).
DisableddisabledSponsorkit is disabled through SPONSORKIT_DISABLE.
PopupBlockedpopup_blockedA browser popup was blocked.
AccessDeniedaccess_deniedThe supporter declined access at the provider.
InvalidStateinvalid_stateThe OAuth state expired or could not be verified.
ProviderErrorprovider_errorThe provider failed during sign-in.
InvalidCodeinvalid_codeThe API rejected the code exchange (400 invalid_code).
CancelledcancelledSign-in was cancelled through crate::SignInOptions::cancel, or the user abandoned it (e.g. nothing was entered at the paste-back prompt).
TimeouttimeoutSign-in exceeded crate::Options::sign_in_timeout (default 300 s).
NetworkErrornetwork_errorThe API could not be reached, or answered 5xx, 429 or something unexpected, during sign_in, open_checkout's sign-in or verify_session.
SessionInvalidsession_invalidThe session token is invalid.
TargetsMismatchtargets_mismatchThe session is bound to different targets.

InvalidConfig#

Wire value: invalid_config

Missing or invalid configuration: no targets, a malformed target, an unknown mock preset, invalid checkout options, (dev-time check) a target that does not exist, or a local environment the SDK cannot work in (an unwritable storage directory, no secure random source).

Disabled#

Wire value: disabled

Sponsorkit is disabled through SPONSORKIT_DISABLE.

PopupBlocked#

Wire value: popup_blocked

A browser popup was blocked. Only the browser SDK produces it; it is listed for parity with the other SDKs.

AccessDenied#

Wire value: access_denied

The supporter declined access at the provider.

InvalidState#

Wire value: invalid_state

The OAuth state expired or could not be verified.

ProviderError#

Wire value: provider_error

The provider failed during sign-in.

InvalidCode#

Wire value: invalid_code

The API rejected the code exchange (400 invalid_code).

Cancelled#

Wire value: cancelled

Sign-in was cancelled through crate::SignInOptions::cancel, or the user abandoned it (e.g. nothing was entered at the paste-back prompt).

Timeout#

Wire value: timeout

Sign-in exceeded crate::Options::sign_in_timeout (default 300 s).

NetworkError#

Wire value: network_error

The API could not be reached, or answered 5xx, 429 or something unexpected, during sign_in, open_checkout's sign-in or verify_session. Error::retry_after carries the API's Retry-After, when it sent one. get_financial_contribution never returns it.

SessionInvalid#

Wire value: session_invalid

The session token is invalid. Only returned by crate::server::verify_session.

TargetsMismatch#

Wire value: targets_mismatch

The session is bound to different targets. Only returned by crate::server::verify_session.

Methods#

as_str#

pub fn as_str(self) -> &'static str

The wire spelling of this code, e.g. "invalid_config".

Returns: &'static str

Trait implementations#

  • impl Clone for ErrorCode
  • impl Copy for ErrorCode
  • impl Debug for ErrorCode
  • impl Display for ErrorCode
  • impl Eq for ErrorCode
  • impl Hash for ErrorCode
  • impl PartialEq for ErrorCode