pub enum ApiError {
Api {
status: u16,
message: String,
},
Authentication(String),
Validation(String),
RateLimit(String),
Timeout,
Network(Error),
Serialization(Error),
Url(ParseError),
}Expand description
Core API error types shared across Polyoxide clients
Variants§
Api
HTTP request failed
Authentication(String)
Authentication failed (401/403)
Validation(String)
Request validation failed (400)
RateLimit(String)
Rate limit exceeded (429)
Timeout
Request timeout
Network(Error)
Network error
Serialization(Error)
JSON serialization/deserialization error
Url(ParseError)
URL parsing error
Implementations§
Source§impl ApiError
impl ApiError
Sourcepub async fn from_response(response: Response) -> Self
pub async fn from_response(response: Response) -> Self
Create error from HTTP response
Sourcepub fn is_retriable(&self) -> bool
pub fn is_retriable(&self) -> bool
Whether re-sending the same request could plausibly produce a different result.
Intended as the canonical input to a caller’s retry policy, so consumers do not have to re-derive retriability from status codes or error prose.
Retriable: rate limits, timeouts, connection failures, 425 Too Early
(Polymarket’s matching engine restarting), and any 5xx. Not retriable:
authentication failures, validation failures, and local encode/decode errors —
all of which are deterministic for a given request.
Note this describes the error, not the operation: a retriable error on a non-idempotent request (order placement) still needs caller-side judgement about whether resubmitting is safe.
Trait Implementations§
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<ParseError> for ApiError
impl From<ParseError> for ApiError
Source§fn from(source: ParseError) -> Self
fn from(source: ParseError) -> 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,
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.