#[non_exhaustive]pub enum Error {
Accounted {
source: Box<Error>,
attempts: Vec<Attempt>,
run: Option<RunSpend>,
},
Api {
status: ApiStatus,
message: Option<String>,
retry_after: Option<Duration>,
},
InsufficientCredits,
Exhausted {
attempts: Vec<Attempt>,
last: Option<Box<FailedPage>>,
reason: StopReason,
source: Option<Box<Error>>,
},
BudgetExceeded {
kind: BudgetKind,
attempts: Vec<Attempt>,
},
Auth {
cause: AuthCause,
message: String,
},
Transport(Error),
Decode(Error),
ResponseTooLarge {
limit: usize,
status: ApiStatus,
},
Config(String),
}Expand description
An error from a call to Spider Cloud.
Running out of credits is its own variant rather than a status code, because it is the one failure that must never be retried: every attempt after the balance hits zero fails the same way, and some of them still cost money.
A rate limit is not its own variant either. A 429 arrives as Error::Api
with its status and its retry_after, and Error::recovery is what an
agent reads to learn that the answer is to wait.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Accounted
A call error together with its operation trail and optional run totals.
Fields
Api
The service rejected the call itself. This is never a target site’s status, only the status of your request to Spider Cloud.
Fields
InsufficientCredits
The account has no credits left. Do not retry this.
Exhausted
Pages came back, none of them usable, and the walk then stopped.
A walk that never got a page back keeps the call error in Error::Accounted,
Error::Api, Error::Auth or Error::Transport, because what
stopped it is a fact about the call rather than about a page.
Fields
last: Option<Box<FailedPage>>The last failure, when there was one to keep.
reason: StopReasonWhy the policy stopped the walk.
BudgetExceeded
The call would have cost more than the budget allowed.
Fields
kind: BudgetKindWhich cap stopped it.
Auth
No usable API key, the key was rejected, or signing in did not produce one.
Fields
Transport(Error)
Sending the request or reading its response failed at the HTTP layer.
Decode(Error)
The response did not have the shape this version of the crate expects.
ResponseTooLarge
The answer ran past the size the client was built to read.
Only a client built with max_response_bytes can see this. Inside a
page operation it arrives as the source of an Error::Exhausted
whose attempts include the cut-off call, so nothing spent before it is
lost.
Fields
Config(String)
The client was built with settings that cannot work.
Implementations§
Source§impl Error
impl Error
Sourcepub fn into_cause(self) -> Error
pub fn into_cause(self) -> Error
Consume the accounting wrapper after recording its trail.
Sourcepub fn run_spend(&self) -> Option<RunSpend>
pub fn run_spend(&self) -> Option<RunSpend>
Run totals on an error from a client with shared credit admission.
Sourcepub fn attempts(&self) -> &[Attempt]
pub fn attempts(&self) -> &[Attempt]
Calls made before this error, including calls with unknown charges.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether trying the same call again could plausibly work.
False for anything caused by the request itself, and false for running
out of credits, which only gets worse with repetition. On the call plane it
is a rate limit or a status ApiStatus::is_transient names, the same set
the send loop retries.
Sourcepub fn recovery(&self) -> Recovery
pub fn recovery(&self) -> Recovery
What to do about this error.
A rate limit and a transient service failure say to wait, with the service’s own figure when it sent one. A refused key or a failed sign in say to sign in again. A key that was never there, a local path problem, an empty balance, a cap and a malformed request or response are permanent, because sending again does not create a key, fix a path or refill an account. An exhausted walk answers from the call error that stopped it, when there was one, and from the policy’s reason otherwise.
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()