#[non_exhaustive]pub enum Error {
Auth {
response: Option<ErrorBody>,
},
NotFound {
response: Option<ErrorBody>,
},
Validation {
message: String,
response: Option<ErrorBody>,
},
RateLimit {
retry_after: u32,
limit_type: Option<String>,
response: Option<ErrorBody>,
},
Timeout {
timeout: Duration,
},
Api {
status: u16,
message: String,
response: Option<ErrorBody>,
},
Transport(Error),
Decode(Error),
Build(String),
}Expand description
The error type returned by all fallible SDK calls.
Use Error::is_retryable in custom retry policies and Error::status
for programmatic dispatch by HTTP status code.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Auth
HTTP 401 — the API key was missing, malformed, or rejected.
NotFound
HTTP 404 — the requested resource does not exist.
Validation
HTTP 400 — the request was syntactically valid but the server rejected
its parameters. The message is the SDK’s best guess at a human-readable
reason; the SDK walks envelope keys (detail / message / error)
first, then sorted-key iteration over the remaining keys, preferring
array values over strings.
Fields
RateLimit
HTTP 429 — the caller exceeded a rate limit.
retry_after is populated from the Retry-After header when present
(in seconds, capped at 10s by the retry loop). limit_type is
populated from X-RateLimit-Type when the server sets it
(e.g. "minute", "hour", "day").
Fields
Timeout
A request exceeded its configured timeout. No HTTP status was received.
Api
Any other non-2xx HTTP response.
Fields
Transport(Error)
An HTTP transport-level failure (DNS, connection refused, TLS, etc.).
Send-safe reqwest::Error is preserved for Error::source traversal.
Decode(Error)
A response body failed JSON decoding.
Build(String)
The SDK failed to build a request (URL parse, bad input, etc.). Strictly internal — callers should not see this in practice.
Implementations§
Source§impl Error
impl Error
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns true if this error is one the SDK’s retry loop will recover from.
Retryable:
RateLimit(429)Timeout(transport-level deadline)Api { status: 5xx }(server-side faults)Api { status: 408 }(request timeout reported by server)Transport(DNS/TCP/TLS-level failures)
Not retryable:
Auth/NotFound/Validation(client-side; retry won’t change the answer)Api { status: other 4xx }Decode/Build(programmer/server 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()