Skip to main content

WritError

Enum WritError 

Source
pub enum WritError {
    Api {
        status: u16,
        code: String,
        message: String,
        body: Value,
    },
    RateLimited {
        status: u16,
        code: String,
        message: String,
        body: Value,
        reset_at: Option<String>,
        requests_remaining: Option<i64>,
        pages_remaining: Option<i64>,
    },
    ApiKeyRequired {
        status: u16,
        code: String,
        message: String,
        body: Value,
    },
    InsufficientCredits {
        status: u16,
        code: String,
        message: String,
        body: Value,
    },
    RunTimeout {
        run_id: i64,
        status_url: Option<String>,
        events_url: Option<String>,
    },
    Connection(String),
    Discovery(String),
}
Expand description

Every failure surfaced by this SDK.

The tiered Writ Cloud surface (crate::CloudClient) adds three more non-2xx shapes on top of Api: WritError::RateLimited (429), WritError::ApiKeyRequired (402 api_key_required, or a keyless whole-site crawl refused before any network call), and WritError::InsufficientCredits (any other 402).

Variants§

§

Api

Non-2xx HTTP response from the daemon.

Fields

§status: u16

HTTP status code.

§code: String

Stable machine code: the daemon’s JSON code field when present, otherwise derived from the status (400→bad_request, 401→unauthorized, 403→forbidden, 404→not_found, 409→conflict, 422→unprocessable, 429→rate_limited, 5xx→internal).

§message: String

Human message: JSON errordetailmessage → raw text (truncated to ~500 chars) → HTTP status text.

§body: Value

The parsed JSON body, or the raw text as a JSON string.

§

RateLimited

The keyless daily allowance (requests/day or pages/day, per device or IP) is exhausted — Writ Cloud answered 429. reset_at is when the allowance refills; add an API key for a full metered quota.

Fields

§status: u16

HTTP status (always 429).

§code: String

Stable machine code (body detail.code, else rate_limited).

§message: String

Human message (body detail.message).

§body: Value

The parsed JSON body, or the raw text as a JSON string.

§reset_at: Option<String>

ISO timestamp when the keyless daily allowance resets, if reported.

§requests_remaining: Option<i64>

Keyless requests left today, if reported.

§pages_remaining: Option<i64>

Keyless pages left today, if reported.

§

ApiKeyRequired

A whole-site crawl was requested on the keyless cloud tier (no API key). Crawl is metered and always needs a credential — set an API key (builder api_key or WRIT_API_KEY). Keyless access covers scrape + map. Raised by crate::CloudClient::crawl/crate::CloudClient::crawl_status before any network call, or from a 402 api_key_required response.

Fields

§status: u16

HTTP status (402).

§code: String

Stable machine code (api_key_required).

§message: String

Human message.

§body: Value

The parsed JSON body, or null when refused client-side.

§

InsufficientCredits

The tenant’s crawl-page allotment is spent and the wallet can’t cover the call — Writ Cloud answered 402 (any code other than api_key_required).

Fields

§status: u16

HTTP status (402).

§code: String

Stable machine code.

§message: String

Human message.

§body: Value

The parsed JSON body, or the raw text as a JSON string.

§

RunTimeout

A run(..., wait) call whose SERVER-side budget expired (HTTP 504).

NOT a failure of the run: it is still executing and run_id still addresses it — poll runs().get(run_id), stream runs().events(run_id), or runs().cancel(run_id). Retrying the call would start a SECOND run, which is exactly what carrying the id here is meant to prevent.

Fields

§run_id: i64

The still-running run.

§status_url: Option<String>

Where to read the outcome once terminal, as reported by the daemon.

§events_url: Option<String>

Live SSE stream for this run.

§

Connection(String)

Network failure / timeout / undecodable response (daemon down mid-session).

§

Discovery(String)

No live daemon found at construction time (see DESIGN.md §4).

Trait Implementations§

Source§

impl Debug for WritError

Source§

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

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

impl Display for WritError

Source§

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

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

impl Error for WritError

1.30.0 · 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 WritError

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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