#[non_exhaustive]pub enum Error {
Transport(Error),
Decode(String),
InvalidRequest(String),
Api {
status: u16,
info: ErrorInfo,
},
}Expand description
The single error type surfaced by this crate.
#[non_exhaustive] so new variants can be added without a breaking change.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Transport(Error)
An HTTP transport failure from reqwest (connection, timeout, TLS, …).
Decode(String)
The response body could not be decoded into the expected type.
InvalidRequest(String)
A request was rejected by client-side validation before being sent
(e.g. a distinct/multiple reaction delete missing its name).
Api
A non-2xx response carrying the Ably error envelope.
Implementations§
Source§impl Error
impl Error
Sourcepub fn info(&self) -> Option<&ErrorInfo>
pub fn info(&self) -> Option<&ErrorInfo>
The parsed Ably error envelope, if this is an API error.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether retrying the request that produced this error may succeed.
Transport timeouts/connect failures, HTTP 429, and 5xx are retryable;
decode failures and other API errors are not. The dispatch layer only
actually retries requests that are also idempotency-safe (ADR-0006).
Sourcepub fn is_not_found(&self) -> bool
pub fn is_not_found(&self) -> bool
Ably code 40400: the message was not found.
Sourcepub fn is_rejected_by_rule(&self) -> bool
pub fn is_rejected_by_rule(&self) -> bool
Ably code 42211: the operation was rejected by a room rule.
Sourcepub fn is_rejected_by_moderation(&self) -> bool
pub fn is_rejected_by_moderation(&self) -> bool
Ably code 42213: the operation was rejected by moderation.
Sourcepub fn is_token_error(&self) -> bool
pub fn is_token_error(&self) -> bool
Whether this is an Ably token error (HTTP 401, code in [40140, 40150))
that a configured TokenProvider should renew on (spec RSA4b).
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()