Expand description
What a call can fail with, and how a failure renders.
Error is the one error type every fallible operation returns. It is a
single boxed pointer, so Result<T, Error> costs a pointer beside T
rather than the size of the largest failure; the detail lives behind
Error::kind.
Four things here are not what a plain thiserror enum would do:
- An API failure’s message is extracted from the server’s body in a fixed
order. Servers put the human-readable sentence under
error,error.message,message,detail,detail.messageor a list underdetail, and the SDK reads them in that order so the message a caller sees does not depend on which shape the endpoint chose. SeeApiError::message. - Nothing here prints a header value or a codec error’s input. An
Authorizationheader and a decode error’s excerpt of the body are both in reach of these types, and neither appears inDebugorDisplay. - Text the server chose is escaped and cut before it is printed. An API failure’s message and the request id are the server’s text, and either would otherwise put a line break, a terminal colour or 16 MiB into every log line that prints the error. The accessors for the body and the headers still return them as they arrived.
Retry-Afteris parsed against a caller-suppliednow. Reading the clock inside the parser would make the HTTP-date case untestable without mocking time, so the parser takes the instant to measure against andApiError::retry_afteris the thin wrapper that reads the clock.
Structs§
- ApiError
- An unsuccessful HTTP response, with the body and metadata it came with.
- Error
- Anything a call to the API can fail with.
- Response
Validation Error - A successful HTTP response whose body this SDK could not read.
Enums§
- ApiError
Kind - Which class of API failure a status code puts a response in.
- Error
Kind - Which kind of failure an
Erroris.