Error

The error type of this crate (SponsorkitError in the other SDKs).

On this page

The error type of this crate (SponsorkitError in the other SDKs).

Match on Error::code rather than on the message, which is meant for humans.

use sponsorkit::Error;

pub struct Error { /* private fields */ }

Methods#

new#

pub fn new(code: ErrorCode, message: impl Into<String>) -> Self

Creates an error with the given code and human-readable message.

ParameterType
codeErrorCode
messageimpl Into<String>

Returns: Self

code#

pub fn code(&self) -> ErrorCode

The machine-readable error code.

Returns: ErrorCode

message#

pub fn message(&self) -> &str

The human-readable message.

Returns: &str

retry_after#

pub fn retry_after(&self) -> Option<std::time::Duration>

For [ErrorCode::NetworkError]: how long the API asked to wait before retrying (its Retry-After header, in whole seconds), if it sent one.

Returns: Option<std::time::Duration>

Trait implementations#

  • impl Clone for Error
  • impl Debug for Error
  • impl Display for Error
  • impl From<reqwest::Error> for Error
  • impl std::error::Error for Error