#[non_exhaustive]pub enum Error {
MissingApiKey,
BadRequest {
endpoint: String,
body: String,
},
Unauthorized {
endpoint: String,
},
Forbidden {
endpoint: String,
},
NotFound {
endpoint: String,
},
RateLimited {
endpoint: String,
retry_after: Option<Duration>,
},
InternalServerError {
endpoint: String,
body: String,
},
UnexpectedStatusCode {
endpoint: String,
status: u16,
body: String,
},
Http(Error),
Io(Error),
}Expand description
Errors returned by the Datamaxi+ API client.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
MissingApiKey
No API key was provided explicitly and DATAMAXI_API_KEY is unset or empty.
BadRequest
The API returned a 400 Bad Request; the payload carries the server message.
endpoint is the request path that failed (e.g.
/api/v1/liquidation/heatmap), so failures are diagnosable without
enabling tracing.
Fields
The API returned a 401 Unauthorized (missing or invalid API key).
Fields
The request path that produced this error.
Forbidden
The API returned a 403 Forbidden (the key is valid but lacks access to the resource).
NotFound
The API returned a 404 Not Found (the resource or endpoint does not exist).
endpoint names which of the endpoints 404’d, so the error is
actionable on its own.
RateLimited
The API returned a 429 Too Many Requests (rate limited).
retry_after carries the Retry-After header when present, parsed from
either the delay-seconds or the HTTP-date form (a past date clamps to
zero). This is the server’s actual suggestion and is not clamped to
[RETRY_MAX_DELAY] (that cap only bounds the client’s internal retry
sleeps).
Fields
InternalServerError
The API returned a 500 Internal Server Error; the payload carries the server message.
Fields
UnexpectedStatusCode
The API returned a status code the client does not specifically handle.
Carries the request endpoint, the raw status code, and the (capped)
response body. An unexpected status is exactly the case where the body
is most useful for diagnosis, so — like Error::BadRequest /
Error::InternalServerError — it is preserved rather than discarded.
The body is truncated to a capped length on a UTF-8 char boundary.
Fields
Http(Error)
The underlying HTTP request failed, or the response body could not be
decoded. The failing URL is available via
reqwest::Error::url on the wrapped error.
Io(Error)
Reading the response body failed.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()