1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use crate::data::ErrorResponse;

use thiserror::Error;

#[derive(Error, Debug)]
pub enum Error {
    #[error("Connection closed")]
    ConnectionClosed,
    #[error("Ping timeout")]
    PingTimeout,
    #[error("No data received")]
    NoDataReceived,
    #[error("Trading is disabled when safe=true")]
    TradingIsDisabled,
    #[error("Error received: {response:?}")]
    ErrorReceived { response: ErrorResponse },
    #[error("Unknown record: {record:?}")]
    UnknownRecord { record: String },
    #[error("JsonParseError: {0}")]
    JsonParseError(#[from] serde_json::Error),
    #[error("Websocket error: {0}")]
    WebSocketError(#[from] tokio_tungstenite::tungstenite::Error),
}