cross_ws/error/
mod.rs

1//! cross-ws error module.
2
3use thiserror::Error;
4
5/// Specific error to each backend.
6pub type BackendError = crate::websocket::backend::BackendError;
7
8/// All possible errors emitted by the WebSocket.
9#[derive(Debug, Error)]
10pub enum Error {
11    /// Error emitted if the connection fails.
12    #[error("Connection error: {0:?}")]
13    ConnectionError(BackendError),
14    /// Error emitted if sending a message fails.
15    #[error("Send error: {0:?}")]
16    SendError(BackendError),
17    /// Error emitted if receiving a message fails.
18    #[error("Receive error: {0:?}")]
19    ReceiveError(BackendError),
20    /// Error emitted if a mutex lock fails.
21    #[error("Mutex lock error: {0}")]
22    LockError(String),
23    /// Error emitted if WebSocket creation fails.
24    #[error("WebSocket creation failed")]
25    WebSocketCreationFailed,
26    /// Error emitted if a type cast fails.
27    #[error("Type cast failed: {0}")]
28    CastError(String),
29    /// Error emitted if an unsupported message type is encountered.
30    #[error("Unsupported message type: {0}")]
31    UnsupportedMessageType(String),
32}
33
34/// Result type of cross-ws.
35pub type Result<T> = std::result::Result<T, Error>;