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.
WritError::Api— the daemon answered with a non-2xx HTTP status.WritError::Connection— the daemon could not be reached / the request or stream timed out / the response body could not be decoded.WritError::Discovery— no live daemon could be found at construction.
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
code: StringStable 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).
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
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
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
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
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 Error for WritError
impl Error for WritError
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()