pub enum Error {
Api(Box<ApiError>),
Connection(Box<dyn Error + Send + Sync>),
Timeout {
timeout: Duration,
},
ResponseTooLarge {
limit: usize,
},
Decode {
status: u16,
body_excerpt: String,
source: Error,
},
InvalidResponse {
source: ValidationError,
},
Config(String),
}Expand description
All client failures. Error::Api wraps the unsuccessful-response case;
the other variants cover transport, timeout, decoding, response validation,
and configuration problems.
Variants§
Api(Box<ApiError>)
The server responded with a non-success status. See ApiError.
(Boxed to keep Result<T, Error> small; deref coercion makes the
inner ApiError fields directly accessible.)
Connection(Box<dyn Error + Send + Sync>)
The request could not reach, or the response could not be read from, the server.
Timeout
The request exceeded its per-attempt timeout.
ResponseTooLarge
A response body exceeded the client’s fixed memory-safety limit.
Decode
A 2xx response body could not be decoded as the expected type.
Fields
InvalidResponse
A 2xx response decoded but violated the submitted question contract.
Fields
source: ValidationErrorThe violated request/response invariant. Response content is omitted.
Config(String)
The client was constructed with invalid settings (missing API key, bad base URL, non-positive timeout, …).
Implementations§
Source§impl Error
impl Error
Sourcepub fn status(&self) -> Option<u16>
pub fn status(&self) -> Option<u16>
HTTP status, when the error originated from a server response.
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
The server-requested retry delay, when present.
Sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
The x-typesafe-request-id of the failed request, when present.
Sourcepub fn kind(&self) -> Option<ApiErrorKind>
pub fn kind(&self) -> Option<ApiErrorKind>
The error kind classification, when this is an API error.
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()