use thiserror::Error;
use tokio_tungstenite::tungstenite;
#[derive(Debug, Clone, Error)]
pub enum OKXWsError {
#[error("Parsing error: {0}")]
ParsingError(String),
#[error("OKX error {error_code}: {message}")]
OkxError { error_code: String, message: String },
#[error("JSON error: {0}")]
JsonError(String),
#[error("Client error: {0}")]
ClientError(String),
#[error("Authentication error: {0}")]
AuthenticationError(String),
#[error("Tungstenite error: {0}")]
TungsteniteError(String),
}
impl From<tungstenite::Error> for OKXWsError {
fn from(error: tungstenite::Error) -> Self {
Self::TungsteniteError(error.to_string())
}
}
impl From<String> for OKXWsError {
fn from(msg: String) -> Self {
Self::AuthenticationError(msg)
}
}