#[non_exhaustive]pub enum Error {
Message(String),
Request(Error),
UnexpectedResponse(String),
EzError(Box<EzError>),
PollingExhausted {
task_id: String,
attempts: usize,
interval: Duration,
},
WaitInterrupted {
task_id: String,
request_id: Option<String>,
source: Box<Error>,
},
SolutionDecode {
source: Error,
raw: Box<Value>,
},
}Expand description
Errors produced by request construction, HTTP transport, API responses, and polling.
This enum is #[non_exhaustive]: new variants may be added in future minor
releases, so downstream matches must include a wildcard arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Message(String)
A failure whose only useful detail is its description.
An invalid client configuration arrives here today. Anything a caller would react to programmatically gets a variant of its own instead, so this one is meant to be printed rather than matched on.
Request(Error)
async or blocking only.The HTTP request failed.
Wraps the underlying reqwest::Error, whose is_timeout,
is_connect, and status methods classify the failure.
UnexpectedResponse(String)
The response could not be used, either because it did not decode or because it violated the API contract.
A ready result carrying no solution field lands here too: the task was
billed and the answer is gone, which is a broken contract rather than a
category of its own. Solution::is_missing still tells that case
apart from a solution that was present and null.
EzError(Box<EzError>)
The API reported an error.
This covers both a structured business error and any non-success HTTP
status, so EzError::http_status is always available here.
PollingExhausted
Polling ended before the task reached a terminal state.
Fields
WaitInterrupted
The task was created and billed, but waiting for its result failed.
solve creates the task internally, so the identifier never reaches the
caller on its own. A failure that dropped it would leave a paid-for
result unreachable — hence this variant, whose whole purpose is to carry
the identifier out.
Recover by waiting on the same task again rather than creating a second
one: the service holds a result for five minutes after creation, and a
new task is billed again. Errors that already carry the identifier
themselves are left alone, so a business error still arrives as
Self::EzError and an exhausted budget as Self::PollingExhausted.
Fields
SolutionDecode
A raw solution could not be converted into the requested type.
The raw value travels with the error: a decode failure means the worker returned a shape this release does not model, and that shape is exactly what is needed to diagnose it. The convenience methods consume the task result, so this is the only place it survives.
Implementations§
Source§impl Error
impl Error
Sourcepub fn task_id(&self) -> Option<&str>
pub fn task_id(&self) -> Option<&str>
Returns the identifier of a task that was created and billed, when this failure left one behind.
Creating a task is what costs money, so a failure after that point
leaves a result worth recovering: wait on this identifier again with
wait_for_result instead of creating a second task. The service holds a
result for five minutes after creation.
None means nothing was billed — the failure happened before or during
task creation, so there is nothing to recover.
Which variant the identifier is stored on is an implementation detail; this is the one place to ask.
if let Some(task_id) = error.task_id() {
// The task is still on the service. Waiting again is free.
eprintln!("recover with wait_for_result({task_id})");
}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()