Expand description
Client error types, envelope extraction, and status classifications. Error taxonomy and header parsing for the client, mirroring the TypeSafe Python SDK exception hierarchy:
| Rust | Python SDK | HTTP | Server code |
|---|---|---|---|
ApiErrorKind::BadRequest | TypeSafeBadRequestError | 400 | bad_json |
ApiErrorKind::Authentication | TypeSafeAuthenticationError | 401 | unauthorized |
ApiErrorKind::NotFound | TypeSafeNotFoundError | 404 | unknown_model |
ApiErrorKind::PayloadTooLarge | — | 413 | payload_too_large |
ApiErrorKind::UnprocessableEntity | TypeSafeUnprocessableEntityError | 422 | invalid_body |
ApiErrorKind::RateLimit | TypeSafeRateLimitError | 429 | rate_limited |
ApiErrorKind::Overloaded | TypeSafeAPIOverloadedError | 529 | overloaded |
ApiErrorKind::InternalServer | TypeSafeInternalServerError | 5xx | backend_error / internal_error |
429/529 responses carry retry-after-ms (milliseconds, preferred) and
Retry-After (seconds, or an HTTP-date) headers; both are parsed into
ApiError::retry_after so crate::RetryPolicy can back off exactly
as long as the server asks.
Structs§
- ApiError
- 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.
Enums§
- ApiError
Kind - Coarse classification of an
ApiErrorby status, mirroring the Python SDK exception subclasses. - Error
- All client failures.
Error::Apiwraps the unsuccessful-response case; the other variants cover transport, timeout, decoding, response validation, and configuration problems.
Functions§
- parse_
retry_ after - Parse the retry delay the server asked for, in order of preference: