pub struct BinanceApiError {
pub code: i32,
pub msg: String,
}Expand description
Binance REST API error.
Represents errors returned by the Binance REST API in the format:
{"code": -1121, "msg": "Invalid symbol."}This error type preserves the original Binance error code and message,
and can be converted to the appropriate CoreError variant based on
the error code.
Fields§
§code: i32Binance error code (negative integer)
msg: StringError message from Binance
Implementations§
Source§impl BinanceApiError
impl BinanceApiError
Sourcepub fn from_json(json: &Value) -> Option<Self>
pub fn from_json(json: &Value) -> Option<Self>
Parses a Binance API error from JSON response.
§Arguments
json- The JSON response from Binance API
§Returns
Returns Some(BinanceApiError) if the JSON contains code and msg fields,
None otherwise.
§Example
use ccxt_exchanges::binance::error::BinanceApiError;
use serde_json::json;
let response = json!({"code": -1121, "msg": "Invalid symbol."});
let err = BinanceApiError::from_json(&response);
assert!(err.is_some());
assert_eq!(err.unwrap().code, -1121);Sourcepub fn is_rate_limit(&self) -> bool
pub fn is_rate_limit(&self) -> bool
Returns true if this is a rate limit error.
Rate limit errors have codes:
- -1003: Too many requests
- -1015: Too many orders
Sourcepub fn is_ip_banned(&self) -> bool
pub fn is_ip_banned(&self) -> bool
Returns true if this is an IP ban error.
IP ban errors have code -1003 with specific messages or HTTP 418 status.
Sourcepub fn is_auth_error(&self) -> bool
pub fn is_auth_error(&self) -> bool
Returns true if this is an authentication error.
Sourcepub fn is_invalid_symbol(&self) -> bool
pub fn is_invalid_symbol(&self) -> bool
Returns true if this is an invalid symbol error.
Sourcepub fn is_insufficient_balance(&self) -> bool
pub fn is_insufficient_balance(&self) -> bool
Returns true if this is an insufficient balance error.
Sourcepub fn is_order_not_found(&self) -> bool
pub fn is_order_not_found(&self) -> bool
Returns true if this is an order not found error.
Sourcepub fn to_core_error(&self) -> CoreError
pub fn to_core_error(&self) -> CoreError
Converts this error to the appropriate CoreError variant.
The mapping follows these rules:
- Authentication errors (-2014, -2015, -1022) →
CoreError::Authentication - Rate limit errors (-1003, -1015) →
CoreError::RateLimit - Invalid symbol (-1121) →
CoreError::BadSymbol - Insufficient balance (-2010, -2011) →
CoreError::InsufficientBalance - Order not found (-2013) →
CoreError::OrderNotFound - Invalid order errors →
CoreError::InvalidOrder - Network errors (-1001) →
CoreError::Network - Other errors →
CoreError::Exchange
Trait Implementations§
Source§impl Clone for BinanceApiError
impl Clone for BinanceApiError
Source§fn clone(&self) -> BinanceApiError
fn clone(&self) -> BinanceApiError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BinanceApiError
impl Debug for BinanceApiError
Source§impl Display for BinanceApiError
impl Display for BinanceApiError
Source§impl Error for BinanceApiError
impl Error for BinanceApiError
1.30.0 · 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
Source§impl From<BinanceApiError> for Error
impl From<BinanceApiError> for Error
Source§fn from(e: BinanceApiError) -> Self
fn from(e: BinanceApiError) -> Self
Auto Trait Implementations§
impl Freeze for BinanceApiError
impl RefUnwindSafe for BinanceApiError
impl Send for BinanceApiError
impl Sync for BinanceApiError
impl Unpin for BinanceApiError
impl UnsafeUnpin for BinanceApiError
impl UnwindSafe for BinanceApiError
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<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.