Skip to main content

Error

Enum Error 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Accounted

A call error together with its operation trail and optional run totals.

Fields

§source: Box<Error>

Original error, preserving its variant and recovery advice.

§attempts: Vec<Attempt>

Every attempted call in this operation.

§run: Option<RunSpend>

Totals across the shared run, when configured.

§

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

§status: ApiStatus

The status the service returned.

§message: Option<String>

What the service said, when it said anything.

§retry_after: Option<Duration>

How long to wait before trying again, when the service said.

§

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

§attempts: Vec<Attempt>

What was tried, in order.

§last: Option<Box<FailedPage>>

The last failure, when there was one to keep.

§reason: StopReason

Why the policy stopped the walk.

§source: Option<Box<Error>>

The call error that stopped the walk, when a call rather than a page was what stopped it.

§

BudgetExceeded

The call would have cost more than the budget allowed.

Fields

§kind: BudgetKind

Which cap stopped it.

§attempts: Vec<Attempt>

What was tried before the cap stopped it, in order. Empty when the cap was reached before anything was sent.

§

Auth

No usable API key, the key was rejected, or signing in did not produce one.

Fields

§cause: AuthCause

Which kind of trouble it was, so a caller can tell a key the service refused from a key that was never there.

§message: String

What went wrong, naming places and never values.

§

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

§limit: usize

The most the client was built to read.

§status: ApiStatus

The status the answer arrived with. The body behind it was not read.

§

Config(String)

The client was built with settings that cannot work.

Implementations§

Source§

impl Error

Source

pub fn cause(&self) -> &Error

Original error without the accounting wrapper.

Source

pub fn into_cause(self) -> Error

Consume the accounting wrapper after recording its trail.

Source

pub fn run_spend(&self) -> Option<RunSpend>

Run totals on an error from a client with shared credit admission.

Source

pub fn attempts(&self) -> &[Attempt]

Calls made before this error, including calls with unknown charges.

Source

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.

Source

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.

Source

pub fn spent(&self) -> Credits

The spend that has already happened, when the error knows about any.

Trait Implementations§

Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<RouterConfigError> for Error

Source§

fn from(error: RouterConfigError) -> Error

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Forget for Error

§

impl Freeze for Error

§

impl Move for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more