pub struct ApiError {
pub status: u16,
pub code: Option<String>,
pub message: Option<String>,
pub body: Option<Value>,
pub request_id: Option<String>,
pub retry_after: Option<Duration>,
pub endpoint: Option<String>,
}Expand description
A single unsuccessful HTTP response, with everything a caller needs to react: status, parsed error envelope, request id for support tickets, and the retry delay the server asked for.
Fields§
§status: u16HTTP status code (e.g. 429, 529).
code: Option<String>Machine-readable code from the error envelope (rate_limited, …).
message: Option<String>Human-readable message from the error envelope, if any.
body: Option<Value>The parsed JSON error body, when the body was valid JSON.
request_id: Option<String>The x-typesafe-request-id response header, for support requests.
retry_after: Option<Duration>Delay the server asked the client to wait via retry-after-ms /
Retry-After, if sent.
endpoint: Option<String>METHOD path of the failed request, e.g. POST /v1/systemone.
Implementations§
Source§impl ApiError
impl ApiError
Sourcepub fn kind(&self) -> ApiErrorKind
pub fn kind(&self) -> ApiErrorKind
Classify this error by HTTP status. See ApiErrorKind.
Sourcepub fn is_rate_limit(&self) -> bool
pub fn is_rate_limit(&self) -> bool
True when this is 429 Too Many Requests.
Sourcepub fn is_overloaded(&self) -> bool
pub fn is_overloaded(&self) -> bool
True when this is 529 Overloaded (the openkind/TypeSafe overload status).
Sourcepub fn is_retryable_later(&self) -> bool
pub fn is_retryable_later(&self) -> bool
True for 429 and 529 — the statuses that mean “retry later”.
Trait Implementations§
Source§impl Error for ApiError
impl Error for ApiError
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()