pub enum Error {
Show 13 variants
Api {
code: i64,
msg: String,
},
Http {
status: u16,
body: String,
},
InvalidHeaderValue(InvalidHeaderValue),
Io(Error),
MissingCredentials,
Msg(String),
RateLimited {
retry_after_ms: u64,
},
RateLimitUnsatisfiable {
cost: u32,
burst: u32,
},
Reqwest(Error),
SerdeJson(Error),
TooManyPages {
max: usize,
},
SerdeUrlEncoded(Error),
SerdePathToError(Error<Error>),
}Expand description
Errors returned by http::Client.
Variants§
Api
Bybit answered with a non-zero retCode (see ret_code).
Http
A non-2xx HTTP response whose body is not a Bybit error envelope
(e.g. an HTML page from a CDN or gateway). body may be truncated.
InvalidHeaderValue(InvalidHeaderValue)
A header value (API key, signature, referer) is not a valid HTTP header.
Io(Error)
I/O error.
MissingCredentials
A private endpoint was called on a client created without
api_key/api_secret.
Msg(String)
Other error with a message.
RateLimited
The local rate limiter rejected the request before it was sent.
retry_after_ms is the estimated wait until capacity is available.
RateLimitUnsatisfiable
The local rate limiter can never let this request through: its cost
exceeds the bucket’s burst, or the bucket does not refill. Retrying
will not help; adjust RateLimiterConfig.
Fields
Reqwest(Error)
Transport error (connection, timeout, TLS, …).
SerdeJson(Error)
JSON (de)serialization error.
TooManyPages
A *_all pagination helper fetched max pages without reaching the end.
SerdeUrlEncoded(Error)
Query string serialization error.
SerdePathToError(Error<Error>)
JSON deserialization error with the path of the offending field.
Implementations§
Source§impl Error
impl Error
Sourcepub fn is_timestamp_error(&self) -> bool
pub fn is_timestamp_error(&self) -> bool
Bybit rejected the request timestamp (retCode 10002): the local clock
is off; see http::Client::sync_time.
Sourcepub fn is_rate_limited(&self) -> bool
pub fn is_rate_limited(&self) -> bool
A rate limit was hit: locally (Error::RateLimited), by Bybit
(retCode 10006/10018) or as HTTP 429.
Sourcepub fn is_not_modified(&self) -> bool
pub fn is_not_modified(&self) -> bool
The request was refused because the value is already set (e.g. “leverage not modified”); usually this can be treated as success.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Sending the same request again later may succeed: network errors and
timeouts, rate limits, server errors (HTTP 5xx, retCode 10016) and
timestamp errors (after sync_time).
For orders a timeout does not prove the order was not placed: check
it (e.g. by orderLinkId) before placing it again.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()