SponsorkitError

An error raised by Sponsorkit.

On this page

Exception in sponsorkit.errors.

from sponsorkit import SponsorkitError

Also importable from sponsorkit.errors.

class SponsorkitError(Exception):
    ...

An error raised by Sponsorkit. Inspect code to handle it programmatically.

Example

try:
    sk.sign_in()
except SponsorkitError as e:
    if e.code == "access_denied":
        print("Sign-in was declined at the provider.")
    elif e.code == "network_error" and e.retry_after is not None:
        print(f"Try again in {e.retry_after:.0f} s.")

Constructor#

SponsorkitError(
    code: ErrorCode,
    message: str | None = None,
    *,
    request_id: str | None = None,
    retry_after: float | None = None,
) -> None
ParameterTypeDefaultDescription
codeErrorCoderequiredThe stable error code (see ErrorCode).
messagestr | NoneNoneHuman-readable message; defaults to the code.
request_idstr | NoneNoneThe Sponsorkit-Request-Id of the failed API response, if any.
retry_afterfloat | NoneNoneSeconds from the API's Retry-After header (network_error only).

Attributes#

code#

code: ErrorCode

Stable, machine-readable error code (see ErrorCode).

request_id#

request_id: str | None

The Sponsorkit-Request-Id of the failed API response, when there was one.

retry_after#

retry_after: float | None

network_error only: seconds from the API's Retry-After header, when it sent one.