Error
The error type of this crate (SponsorkitError in the other SDKs).
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>) -> SelfCreates an error with the given code and human-readable message.
| Parameter | Type |
|---|---|
code | ErrorCode |
message | impl Into<String> |
Returns: Self
code#
pub fn code(&self) -> ErrorCodeThe machine-readable error code.
Returns: ErrorCode
message#
pub fn message(&self) -> &strThe 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 Errorimpl Debug for Errorimpl Display for Errorimpl From<reqwest::Error> for Errorimpl std::error::Error for Error