1use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum Error {
8 #[error("websocket error: {0}")]
10 WebSocket(String),
11
12 #[error("channel not found: {0}")]
14 ChannelNotFound(String),
15
16 #[error("authorization failed: {0}")]
18 AuthorizationFailed(String),
19
20 #[error("client not connected: {0}")]
22 ClientNotConnected(String),
23
24 #[error("serialization error: {0}")]
26 Serialization(#[from] serde_json::Error),
27
28 #[error("channel is full")]
30 ChannelFull,
31
32 #[error("{0}")]
34 Other(String),
35}
36
37impl Error {
38 pub fn websocket(msg: impl Into<String>) -> Self {
40 Self::WebSocket(msg.into())
41 }
42
43 pub fn unauthorized(msg: impl Into<String>) -> Self {
45 Self::AuthorizationFailed(msg.into())
46 }
47}