xapi/
error.rs

1use crate::data::ErrorResponse;
2
3use thiserror::Error;
4
5#[derive(Error, Debug)]
6pub enum Error {
7    #[error("Connection closed")]
8    ConnectionClosed,
9    #[error("Connection timeout")]
10    ConnectionTimeout,
11    #[error("No data received")]
12    NoDataReceived,
13    #[error("Trading is disabled when safe=true")]
14    TradingIsDisabled,
15    #[error("Error received: {response:?}")]
16    ErrorResponse { response: ErrorResponse },
17    #[error("Unknown record: {record:?}")]
18    UnknownRecord { record: String },
19    #[error("JsonParseError: {0}")]
20    JsonParseError(#[from] serde_json::Error),
21    #[error("Websocket error: {0}")]
22    WebSocketError(#[from] tokio_tungstenite::tungstenite::Error),
23}