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#
| Variant | Wire value | Meaning |
|---|---|---|
InvalidConfig | 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 | disabled | Sponsorkit is disabled through SPONSORKIT_DISABLE. |
PopupBlocked | popup_blocked | A browser popup was blocked. |
AccessDenied | access_denied | The supporter declined access at the provider. |
InvalidState | invalid_state | The OAuth state expired or could not be verified. |
ProviderError | provider_error | The provider failed during sign-in. |
InvalidCode | invalid_code | The API rejected the code exchange (400 invalid_code). |
Cancelled | 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 | timeout | Sign-in exceeded crate::Options::sign_in_timeout (default 300 s). |
NetworkError | 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. |
SessionInvalid | session_invalid | The session token is invalid. |
TargetsMismatch | targets_mismatch | The 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 strThe wire spelling of this code, e.g. "invalid_config".
Returns: &'static str
Trait implementations#
impl Clone for ErrorCodeimpl Copy for ErrorCodeimpl Debug for ErrorCodeimpl Display for ErrorCodeimpl Eq for ErrorCodeimpl Hash for ErrorCodeimpl PartialEq for ErrorCode