#[non_exhaustive]pub enum Error {
InvalidUrl {
url: String,
reason: &'static str,
},
Invalid(String),
Transport {
base: String,
cause: String,
source: Error,
},
Api(Box<ApiError>),
UnsupportedContract {
served: String,
},
ResponseTooLarge,
Decode(Error),
Accounts(Error),
}Expand description
Everything that can go wrong in this crate.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
InvalidUrl
The Commit API URL cannot be used; nothing was sent.
Invalid(String)
A value passed to the client was refused before anything was sent.
Transport
The request never got an answer (DNS, connection, TLS, timeout).
Fields
Api(Box<ApiError>)
The Commit API answered with an error.
UnsupportedContract
The Commit API answered with a contract this client does not speak.
ResponseTooLarge
The response body was larger than 8 MiB, so it was not read.
Decode(Error)
The response body was not the JSON this client expects.
Accounts(Error)
Silicon Accounts refused or failed a sign-in step (device code, short-lived token, refresh or revocation). The inner error carries the code, a precise message and a hint.
Implementations§
Source§impl Error
impl Error
Sourcepub fn code(&self) -> &str
pub fn code(&self) -> &str
Stable machine-readable code: the API’s error.code, the Silicon Accounts code
(invalid_grant, access_denied, expired_token, …), or a client-side code.
Sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
The request id of the failed response, if any (quote it when reporting a bug).
Sourcepub fn is_unauthenticated(&self) -> bool
pub fn is_unauthenticated(&self) -> bool
True when the Commit API refused the credential (HTTP 401): refresh the access token (or sign in again) and retry.
Sourcepub fn is_sign_in_refused(&self) -> bool
pub fn is_sign_in_refused(&self) -> bool
True when Silicon Accounts refused a refresh token or short-lived token for good
(invalid_grant): the sign-in ended or the token cannot be used, so sign in again.
Sourcepub fn is_transient(&self) -> bool
pub fn is_transient(&self) -> bool
True when nobody answered or the answer was a temporary failure (5xx, 429): the request may or may not have been applied.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()