pub struct ApiError {
pub status_code: u16,
pub error_type: Option<String>,
pub message: String,
pub attempt: u32,
pub http_method: Option<String>,
pub path: Option<String>,
pub data: Option<Value>,
}Expand description
An error response returned by the Apify API.
This is raised for HTTP requests that reach the API but return a non-success
status code. It mirrors the ApifyApiError of the reference clients and exposes
the parsed error type, the human-readable message, the HTTP status_code,
the number of the final attempt, and the request http_method/path.
Fields§
§status_code: u16HTTP status code of the error response.
error_type: Option<String>The machine-readable error type returned by the API (e.g. record-not-found).
message: StringHuman-readable description of the error returned by the API.
attempt: u32Number of the API call attempt that produced this error (1-based).
http_method: Option<String>HTTP method of the API call (e.g. GET, POST).
path: Option<String>Full path of the API endpoint (URL excluding origin).
data: Option<Value>Additional structured data provided by the API about the error, if any.
Implementations§
Source§impl ApiError
impl ApiError
Sourcepub fn is_invalid_request(&self) -> bool
pub fn is_invalid_request(&self) -> bool
true for HTTP 400 Bad Request, typically because the request failed validation.
The reference clients throw a distinct InvalidRequestError subclass for this status;
since Rust has no exception hierarchy to mirror, these is_* predicates are the
idiomatic equivalent classification on the one ApiError type.
true for HTTP 401 Unauthorized: the token is missing or invalid.
Sourcepub fn is_forbidden(&self) -> bool
pub fn is_forbidden(&self) -> bool
true for HTTP 403 Forbidden: the token lacks permission for the operation.
Sourcepub fn is_not_found(&self) -> bool
pub fn is_not_found(&self) -> bool
true for HTTP 404 Not Found.
Most get-style methods already map a 404 to None rather than an error (see e.g.
crate::clients::actor::ActorClient::get), so this is mainly useful for the methods
that return other errors directly, e.g. crate::clients::actor::ActorClient::start
with a nonexistent Actor ID.
Sourcepub fn is_conflict(&self) -> bool
pub fn is_conflict(&self) -> bool
true for HTTP 409 Conflict.
Sourcepub fn is_rate_limited(&self) -> bool
pub fn is_rate_limited(&self) -> bool
true for HTTP 429 Too Many Requests. The client already retries these internally (see
crate::ApifyClientBuilder::max_retries), so this surfaces only once retries are
exhausted.
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
true for an HTTP 5xx status. Like is_rate_limited, the
client already retries these internally, so this surfaces only once retries are
exhausted.
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()