1use thiserror::Error;
7
8#[derive(Debug, Error, Clone, PartialEq, Eq)]
13pub enum WsError {
14 #[error("authentication token missing")]
16 AuthMissing,
17
18 #[error("authentication token invalid")]
20 AuthInvalid,
21
22 #[error("too many connections")]
24 TooManyConnections,
25
26 #[error("broadcast channel full")]
28 BroadcastFull,
29
30 #[error("invalid message")]
32 InvalidMessage,
33
34 #[error("connection closed")]
36 Closed,
37}
38
39#[allow(
43 clippy::unwrap_used,
44 clippy::expect_used,
45 clippy::indexing_slicing,
46 clippy::panic
47)]
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn display_messages() {
54 assert_eq!(
55 WsError::AuthMissing.to_string(),
56 "authentication token missing"
57 );
58 assert_eq!(
59 WsError::AuthInvalid.to_string(),
60 "authentication token invalid"
61 );
62 assert_eq!(
63 WsError::TooManyConnections.to_string(),
64 "too many connections"
65 );
66 assert_eq!(WsError::BroadcastFull.to_string(), "broadcast channel full");
67 assert_eq!(WsError::InvalidMessage.to_string(), "invalid message");
68 assert_eq!(WsError::Closed.to_string(), "connection closed");
69 }
70
71 #[test]
72 fn clone_eq() {
73 let e = WsError::AuthMissing;
74 assert_eq!(e.clone(), WsError::AuthMissing);
75 assert_ne!(WsError::AuthMissing, WsError::Closed);
76 }
77}