use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("websocket error: {0}")]
WebSocket(String),
#[error("channel not found: {0}")]
ChannelNotFound(String),
#[error("authorization failed: {0}")]
AuthorizationFailed(String),
#[error("client not connected: {0}")]
ClientNotConnected(String),
#[error("serialization error: {0}")]
Serialization(#[from] serde_json::Error),
#[error("channel is full")]
ChannelFull,
#[error("{0}")]
Other(String),
}
impl Error {
pub fn websocket(msg: impl Into<String>) -> Self {
Self::WebSocket(msg.into())
}
pub fn unauthorized(msg: impl Into<String>) -> Self {
Self::AuthorizationFailed(msg.into())
}
}