#[derive(thiserror::Error, Debug)]
pub enum WebsocketError {
#[error("Invalid WebSocket request URL configured")]
InvalidRequest,
#[error("WebSocket connection failed: {0}")]
ConnectionError(#[from] tokio_tungstenite::tungstenite::Error),
#[error("Invalid WebSocket URL: {0}")]
UrlError(#[from] UrlError),
#[error("HTTP error: {0}")]
HttpError(#[from] http::Error),
#[error("Invalid WebSocket header value: {0}")]
InvalidHeader(#[from] http::header::InvalidHeaderValue),
#[error("JSON error: {0}")]
JsonError(#[from] serde_json::Error),
#[error("TLS error: {0}")]
TLSError(String),
#[error("The WebSocket connection was unauthorized")]
Unauthorized,
#[error("WebSocket is already connected")]
AlreadyConnected,
#[error("WebSocket is not connected")]
NotConnected,
#[error("Failed to send message to WebSocket")]
SendError,
#[error("Internal channel communication error")]
ChannelError,
#[error("Operation timed out")]
Timeout,
}
#[derive(thiserror::Error, Debug)]
pub enum UrlError {
#[error(transparent)]
Http(#[from] http::uri::InvalidUri),
#[error(transparent)]
Url(#[from] url::ParseError),
}
pub type WebsocketResult<T> = Result<T, WebsocketError>;