#[non_exhaustive]pub enum Error {
Graphql {
query_name: String,
status: StatusCode,
messages: String,
errors: Vec<GraphqlErrorEntry>,
},
RateLimited {
query_name: String,
retry_after: Option<Duration>,
limit: Option<u64>,
remaining: Option<u64>,
messages: String,
},
UnexpectedStatus {
query_name: String,
status: StatusCode,
body: String,
},
Connection {
query_name: String,
attempts: u32,
source: Error,
},
MissingField {
query_name: String,
field: String,
},
Decode {
query_name: String,
source: Error,
},
CurrencyUnderflow(u64, u64),
InvalidCurrency(String),
}Expand description
Errors returned by the Mina Archive SDK.
#[non_exhaustive], so a match needs a _ arm. A new failure mode — a
new server error class, a new transport condition — must not be an SDK
major release, and adding a variant to an exhaustively matched enum is
breaking.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Graphql
The GraphQL endpoint returned one or more errors. Not retried.
Note status is almost always 200: the API answers every GraphQL-level
error with HTTP 200 and a populated errors array. extensions.status
is a payload field, not the HTTP status.
RateLimited
The server’s rate limiter rejected the request with HTTP 429.
This is the only non-200 the API emits under normal operation, so unlike most 4xx it unambiguously means “slow down”, and it is the one case where retrying the identical request is correct.
Fields
UnexpectedStatus
A non-2xx response that is not GraphQL-shaped.
The usual cause is a URL pointing somewhere the server does not serve:
the endpoint is the root path /, and /graphql returns 404 with an
HTML or plain-text body.
Connection
Failed to connect after exhausting all retry attempts.
MissingField
A required field was missing in an otherwise-successful response — most likely a schema mismatch.
Decode
Failed to deserialize the response body.
CurrencyUnderflow(u64, u64)
Currency subtraction would underflow.
InvalidCurrency(String)
String could not be parsed as a Mina/nanomina currency value.
Implementations§
Source§impl Error
impl Error
Sourcepub fn graphql_codes(&self) -> Vec<&str>
pub fn graphql_codes(&self) -> Vec<&str>
The extensions.code values carried by a Error::Graphql, in order.
Empty for every other variant, and for masked errors, which arrive with
no extensions at all — so an empty result means “no code was sent”,
never “no error occurred”.
Sourcepub fn has_graphql_code(&self, code: &str) -> bool
pub fn has_graphql_code(&self, code: &str) -> bool
True when any entry carries the given extensions.code.
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()