pub enum ReroutError {
Api {
code: String,
status: u16,
message: String,
extra: Box<ApiErrorDetails>,
},
Network {
message: String,
},
Timeout {
message: String,
},
Unexpected {
status: u16,
message: String,
},
Decode {
message: String,
},
Config {
code: String,
message: String,
},
}Expand description
Every error surfaced by the SDK.
Match on the variant for branching logic, and read ReroutError::code
for the stable string identifier (e.g. bad_target_url, rate_limited).
Variants§
Api
The server replied with a non-2xx status.
code is the stable identifier — preferring the API’s code when one
was provided in the JSON body, falling back to a synthetic
status-derived code otherwise.
Fields
extra: Box<ApiErrorDetails>Extra fields (path, timestamp, details) when supplied.
Boxed to keep the ReroutError enum compact — the optional
diagnostics rarely matter on the hot path.
Network
The request never reached the server (DNS, TLS, connection reset, …).
Timeout
The request was aborted after exceeding the client timeout.
Unexpected
The server returned 2xx but the body could not be decoded as JSON.
Fields
Decode
A JSON body failed to decode against the expected schema.
Config
The client was misconfigured (missing API key, invalid base URL, …).
code mirrors the synthetic codes the API would otherwise use
(e.g. missing_api_key, invalid_base_url).
Implementations§
Source§impl ReroutError
impl ReroutError
Sourcepub fn code(&self) -> &str
pub fn code(&self) -> &str
The stable string error code — either from the API or a synthetic one.
Use this for branching logic (if err.code() == "rate_limited" { ... })
rather than parsing the message.
Sourcepub fn is_rate_limited(&self) -> bool
pub fn is_rate_limited(&self) -> bool
true when this is an HTTP 429 (rate_limited) response.
Caller should back off and retry with jitter.
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
true when this is an HTTP 5xx response — a server-side issue.
Trait Implementations§
Source§impl Debug for ReroutError
impl Debug for ReroutError
Source§impl Display for ReroutError
impl Display for ReroutError
Source§impl Error for ReroutError
impl Error for ReroutError
1.30.0 · 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()