#[non_exhaustive]pub enum Error<E> {
RequestConstruction(RequestError),
Transport(TransportError),
Timeout(TimeoutKind),
Protocol(ProtocolError),
Redirect(RedirectError),
Api(ResponseValue<E>),
UnexpectedStatus {
status: StatusCode,
headers: HeaderMap,
body: Bytes,
},
Decode {
status: StatusCode,
headers: HeaderMap,
path: String,
body: Bytes,
truncated: bool,
},
InterruptedBody(TransportError),
}Expand description
The closed error taxonomy shared by every spargen-generated client. E is the
operation’s typed error body (an enum when several error statuses are documented).
Nine variants are constructed; taxonomy class #10 (cancellation) is a documented drop-safety
guarantee, not a variant (see the crate docs). Every variant implements std::error::Error
with full source chains, and Debug never leaks secrets.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
RequestConstruction(RequestError)
#1 — invalid base URL, or parameter/body serialization failure (near-impossible by construction).
Transport(TransportError)
#2 — DNS failure, connection refused/reset, TLS handshake or certificate error.
Timeout(TimeoutKind)
#3 — connect vs total-request timeout (as configured on the injected client).
Protocol(ProtocolError)
#4 — malformed HTTP or decompression failure.
Redirect(RedirectError)
#5 — redirect-policy exhaustion (per the injected client’s policy).
Api(ResponseValue<E>)
#6 — a documented non-success status parsed into the operation’s typed error body.
UnexpectedStatus
#7 — an undocumented status; the raw body is preserved for forensics.
Fields
status: StatusCodeThe response status.
Decode
#8 — the response body failed to deserialize; retains the response status and headers (so the status and a request-ID header survive a body the client cannot read), the serde error path, and the (capped) raw body. For a streamed item they are those of the response that carried the malformed frame.
Fields
status: StatusCodeThe response status.
InterruptedBody(TransportError)
#9 — the connection dropped mid-stream on a streamed response.
Implementations§
Source§impl<E> Error<E>
impl<E> Error<E>
Sourcepub fn request_construction(source: impl Error + Send + Sync + 'static) -> Self
pub fn request_construction(source: impl Error + Send + Sync + 'static) -> Self
Build a request-construction error from any owned error value.
Sourcepub fn request_message(message: impl Into<String>) -> Self
pub fn request_message(message: impl Into<String>) -> Self
Build a request-construction error from a static message.
Sourcepub fn from_reqwest(error: Error) -> Self
pub fn from_reqwest(error: Error) -> Self
Classify a reqwest error into the closest runtime taxonomy class.
Sourcepub fn is_transient(&self) -> bool
pub fn is_transient(&self) -> bool
Whether the failure is worth retrying: transport failures, timeouts, 429, and 5xx
Lets callers wrap any retry policy around the client without spargen
shipping one.
Trait Implementations§
Source§impl<E: Error + 'static> Error for Error<E>
impl<E: Error + 'static> Error for Error<E>
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()