binance_client/
error.rs

1//!
2//! The Binance error.
3//!
4
5use thiserror::Error;
6
7use crate::http_api_v3::data::error::Error as ResponseError;
8
9///
10/// The Binance error.
11///
12#[derive(Debug, Error)]
13pub enum Error {
14    /// The request URL parsing error. Can happen on invalid user input.
15    #[error("URL {0} parsing: {1}")]
16    UrlParsing(reqwest::UrlError, String),
17    /// The request building error. Can happen on invalid user input.
18    #[error("request building: {0}")]
19    RequestBuilding(reqwest::Error),
20    /// The authorization keys data missing. The client was created without them.
21    #[error("authorization keys missing. Please, add create a client with keys")]
22    AuthorizationKeysMissing,
23    /// The request execution error. Usually happens due to some network errors.
24    #[error("request execution: {0}")]
25    RequestExecution(reqwest::Error),
26    /// The response reading error.
27    #[error("response reading: {0}")]
28    ResponseReading(reqwest::Error),
29    /// The response parsing error. Binance returned invalid data or the data model must be updated.
30    #[error("response parsing: {0} ({1})")]
31    ResponseParsing(serde_json::Error, String),
32    /// The response is valid, but Binance returned an application-level error.
33    #[error("response error: {0:?}")]
34    ResponseError(ResponseError),
35    /// The WebSocket error.
36    #[error("WebSocket: {0}")]
37    WebSocket(websocket::WebSocketError),
38}