armature_websocket/
error.rs

1//! Error types for WebSocket operations.
2
3use thiserror::Error;
4
5/// WebSocket error type.
6#[derive(Error, Debug)]
7pub enum WebSocketError {
8    /// Connection error
9    #[error("Connection error: {0}")]
10    Connection(String),
11
12    /// Protocol error
13    #[error("Protocol error: {0}")]
14    Protocol(#[from] tungstenite::Error),
15
16    /// IO error
17    #[error("IO error: {0}")]
18    Io(#[from] std::io::Error),
19
20    /// Serialization error
21    #[error("Serialization error: {0}")]
22    Serialization(#[from] serde_json::Error),
23
24    /// Connection not found
25    #[error("Connection not found: {0}")]
26    ConnectionNotFound(String),
27
28    /// Room not found
29    #[error("Room not found: {0}")]
30    RoomNotFound(String),
31
32    /// Connection closed
33    #[error("Connection closed")]
34    ConnectionClosed,
35
36    /// Send error
37    #[error("Failed to send message: {0}")]
38    Send(String),
39
40    /// Timeout error
41    #[error("Operation timed out")]
42    Timeout,
43
44    /// TLS error
45    #[error("TLS error: {0}")]
46    Tls(String),
47
48    /// Invalid URL
49    #[error("Invalid URL: {0}")]
50    InvalidUrl(String),
51
52    /// Server error
53    #[error("Server error: {0}")]
54    Server(String),
55}
56
57/// Result type for WebSocket operations.
58pub type WebSocketResult<T> = Result<T, WebSocketError>;
59