#[non_exhaustive]pub enum ErrorCode {
BadRequest,
NoRouteFound,
InsufficientLiquidity,
SolveTimeout,
ServiceUnavailable,
ServerError,
NotFound,
Unknown(String),
}Expand description
A structured error code returned by the Fynd RPC API.
Mapped from the raw string code field in
fynd_rpc_types::ErrorResponse.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
BadRequest
The request was malformed or contained invalid parameters.
Server codes: BAD_REQUEST, INVALID_ORDER.
NoRouteFound
No swap route exists between the requested token pair.
Server code: NO_ROUTE_FOUND.
InsufficientLiquidity
A route exists but available pool liquidity is too shallow for the requested amount.
Server code: INSUFFICIENT_LIQUIDITY.
SolveTimeout
The solver timed out before returning a route. Retrying may succeed.
Server code: TIMEOUT.
The server is temporarily unavailable (overloaded, queue full, stale data, or not yet initialised). Retrying after a short backoff should succeed.
Server codes: QUEUE_FULL, SERVICE_OVERLOADED, STALE_DATA, NOT_READY.
ServerError
The server encountered an internal error processing the request. Not retryable.
Server codes: ALGORITHM_ERROR, INTERNAL_ERROR, FAILED_ENCODING.
NotFound
The requested endpoint does not exist. Indicates a client misconfiguration.
Server code: NOT_FOUND.
Unknown(String)
A truly unrecognised server error code. The raw string is preserved for debugging.
Implementations§
Source§impl ErrorCode
impl ErrorCode
Sourcepub fn from_server_code(code: &str) -> Self
pub fn from_server_code(code: &str) -> Self
Map a raw server error code string to a typed ErrorCode.
Unknown codes are wrapped in ErrorCode::Unknown rather than panicking.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns true if this error code indicates that the request is safe to retry.
Only SolveTimeout and
ServiceUnavailable are retryable; all other codes
represent permanent failures.
Trait Implementations§
impl Eq for ErrorCode
impl StructuralPartialEq for ErrorCode
Auto Trait Implementations§
impl Freeze for ErrorCode
impl RefUnwindSafe for ErrorCode
impl Send for ErrorCode
impl Sync for ErrorCode
impl Unpin for ErrorCode
impl UnsafeUnpin for ErrorCode
impl UnwindSafe for ErrorCode
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more