#[non_exhaustive]pub enum UsdmError {
Api(ApiError),
Venue {
status: u16,
code: i64,
msg: String,
},
RateLimited {
retry_after: Option<Duration>,
},
IpBanned {
retry_after: Option<Duration>,
},
RegionBlocked {
msg: String,
},
Forbidden {
msg: String,
},
}Expand description
Error type for USDⓈ-M futures API operations.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Api(ApiError)
Transport, decoding, or an error body in a shape Binance does not use.
Venue
Binance refused the request with its {"code", "msg"} body: an unknown
symbol is 400 with code -1121.
Fields
RateLimited
Still answered 429 after the retry schedule ran out.
IpBanned
418: Binance has banned this IP for continuing after a 429. Every
request on the same WeightBudget waits
until the ban lifts.
Fields
RegionBlocked
451: Binance does not serve the caller’s location.
Forbidden
403: Binance’s web application firewall refused the request.
Implementations§
Trait Implementations§
Source§impl Classify for UsdmError
Api delegates, and Venue follows the status rule with Binance’s code
in decimal. A 429 is RateLimited, and a ban, a region block and a
firewall refusal are all Restricted: Binance documents its 403 as the
firewall’s, not as a credential failure (D14). So a 429, and a 408,
425 or 5xx however its body is shaped, are retriable, and a ban, a region
block and a firewall refusal are not: sending again does not change them,
and sending after a 418 lengthens the ban.
impl Classify for UsdmError
Api delegates, and Venue follows the status rule with Binance’s code
in decimal. A 429 is RateLimited, and a ban, a region block and a
firewall refusal are all Restricted: Binance documents its 403 as the
firewall’s, not as a credential failure (D14). So a 429, and a 408,
425 or 5xx however its body is shaped, are retriable, and a ban, a region
block and a firewall refusal are not: sending again does not change them,
and sending after a 418 lengthens the ban.
A region block is the venue answering as designed, so it is not a fault. A
429’s or a ban’s Classify::retry_after is its Retry-After, clamped
to 3 days: for a ban, the time it lifts.
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 UsdmError
impl Error for UsdmError
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<ApiError> for UsdmError
Binance’s one decode: an unsuccessful response, by status first.
impl From<ApiError> for UsdmError
Binance’s one decode: an unsuccessful response, by status first.
418, 429, 451 and 403 go by status alone: their bodies were not
observed from a test IP, and the status is what decides what a caller
should do. Anything else with Binance’s {code, msg} body is
Venue; any other body stays core’s
ApiError::Response, its message and body clipped and its Retry-After
clamped to 3 days, as every arm reads it. Every other ApiError stays
core’s.
A 418’s body is Binance’s -1003 text, which names when the ban ends.
The error’s fields have no room for it, so it is logged at WARN under
polyoxide_binance::usdm::error; the send loop warns of the hold itself,
naming the path.
Auto Trait Implementations§
impl !RefUnwindSafe for UsdmError
impl !UnwindSafe for UsdmError
impl Freeze for UsdmError
impl Send for UsdmError
impl Sync for UsdmError
impl Unpin for UsdmError
impl UnsafeUnpin for UsdmError
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.