use thiserror::Error;
#[derive(Debug, Error)]
pub enum HorizonError {
#[error("Configuration error: {0}")]
ConfigError(String),
#[error("Connection failed: {0}")]
ConnectionFailed(String),
#[error("Authentication failed: {0}")]
AuthFailed(String),
#[error("Send failed: {0}")]
SendFailed(String),
#[error("WebSocket error: {0}")]
WebSocket(String),
#[error("Serialization error: {0}")]
Serialization(String),
#[error("Deserialization error: {0}")]
Deserialization(String),
#[error("Timeout: {0}")]
Timeout(String),
#[error("Not connected")]
NotConnected,
#[error("Already connected")]
AlreadyConnected,
}
impl From<serde_json::Error> for HorizonError {
fn from(e: serde_json::Error) -> Self {
HorizonError::Serialization(e.to_string())
}
}
impl From<tokio_tungstenite::tungstenite::Error> for HorizonError {
fn from(e: tokio_tungstenite::tungstenite::Error) -> Self {
HorizonError::WebSocket(e.to_string())
}
}