#[non_exhaustive]pub enum ApiError {
Response(Box<ErrorResponse>),
Validation(String),
Transport(TransportError),
Serialization(Error),
Url(ParseError),
Refused(Refused),
Sign(Box<dyn Error + Send + Sync>),
}Expand description
Core API error types shared across Polyoxide clients
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Response(Box<ErrorResponse>)
The server answered with an unsuccessful status. Its class is the status’s.
Validation(String)
The client refused the request before sending it: bad input, or missing configuration.
Transport(TransportError)
The transport failed: no response arrived, or its body could not be read. Its class is its kind’s.
Serialization(Error)
JSON serialization/deserialization error
Url(ParseError)
URL parsing error
Refused(Refused)
The throttle refused a cost no layer can ever hold, and nothing was sent.
Sign(Box<dyn Error + Send + Sync>)
An Authenticator could not sign the request,
and nothing was sent. Carries the venue’s own error, which the venue’s
From<ApiError> takes back out.
Implementations§
Source§impl ApiError
impl ApiError
Sourcepub async fn from_response(response: Response) -> Self
pub async fn from_response(response: Response) -> Self
Read an unsuccessful response whole, as ApiError::Response.
Trait Implementations§
Source§impl Classify for ApiError
The class each variant reports.
impl Classify for ApiError
The class each variant reports.
ApiError::Response follows the status rule, with any status outside
400–599 a Class::Decode (a 2xx that a caller found wanting, such as a
ping whose body says it is not ok), and a 429’s wait its Retry-After.
A 451 is not a fault: the venue does not serve the caller’s region, as
designed. ApiError::Validation and ApiError::Sign are a
Class::InvalidRequest: the client refused the request, or could not
sign it, and nothing was sent.
Classify::retry_after is a response’s Retry-After whatever its
status, and None for every other variant.
Source§fn is_fault(&self) -> bool
fn is_fault(&self) -> bool
Source§fn retry_after(&self) -> Option<Duration>
fn retry_after(&self) -> Option<Duration>
Some of zero.Source§fn is_retriable(&self) -> bool
fn is_retriable(&self) -> bool
Class::is_retriable).Source§impl Error for ApiError
impl Error for ApiError
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()
Source§impl From<ErrorResponse> for ApiError
impl From<ErrorResponse> for ApiError
Source§fn from(response: ErrorResponse) -> Self
fn from(response: ErrorResponse) -> Self
Source§impl From<ParseError> for ApiError
impl From<ParseError> for ApiError
Source§fn from(source: ParseError) -> Self
fn from(source: ParseError) -> Self
Source§impl From<TransportError> for ApiError
impl From<TransportError> for ApiError
Source§fn from(source: TransportError) -> Self
fn from(source: TransportError) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for ApiError
impl !UnwindSafe for ApiError
impl Freeze for ApiError
impl Send for ApiError
impl Sync for ApiError
impl Unpin for ApiError
impl UnsafeUnpin for ApiError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<E> RequestError for E
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.