#[non_exhaustive]pub enum Error {
Config(String),
InvalidRequest(String),
Api(Box<ApiError>),
Connection {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Timeout {
timeout: Duration,
},
ResponseValidation {
status: u16,
field_path: String,
request_id: Option<String>,
endpoint: String,
},
}Expand description
Every error this crate can return.
The API key never appears in any error. The top-level error is
#[non_exhaustive]: match on the variants you handle and keep a wildcard
arm for forward compatibility.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Config(String)
The client could not be constructed: a missing, empty, or invalid API key, an invalid timeout, or invalid retry policy settings.
InvalidRequest(String)
The request failed client-side validation before any network I/O.
Api(Box<ApiError>)
The server returned a non-2xx response.
Connection
The error variant: no HTTP response arrived.
Fields
Timeout
The attempt exceeded the per-attempt timeout. A kind of connection error.
ResponseValidation
A 2xx response body did not match the expected schema.
Implementations§
Source§impl Error
impl Error
Sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
Returns true when this error is a timeout.
Sourcepub fn is_connection(&self) -> bool
pub fn is_connection(&self) -> bool
Returns true when this error is a connection error. Timeouts count
as connection errors.
Sourcepub fn status(&self) -> Option<u16>
pub fn status(&self) -> Option<u16>
Returns the HTTP status code when this error came from a response.
Sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
Returns the x-typesafe-request-id when this error came from a response.
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()