use thiserror::Error;
#[derive(Error, Debug)]
pub enum WebSocketError {
#[error("Connection error: {0}")]
Connection(String),
#[error("Protocol error: {0}")]
Protocol(#[from] tungstenite::Error),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Serialization error: {0}")]
Serialization(#[from] serde_json::Error),
#[error("Connection not found: {0}")]
ConnectionNotFound(String),
#[error("Room not found: {0}")]
RoomNotFound(String),
#[error("Connection closed")]
ConnectionClosed,
#[error("Failed to send message: {0}")]
Send(String),
#[error("Operation timed out")]
Timeout,
#[error("TLS error: {0}")]
Tls(String),
#[error("Invalid URL: {0}")]
InvalidUrl(String),
#[error("Server error: {0}")]
Server(String),
}
pub type WebSocketResult<T> = Result<T, WebSocketError>;