rsiot/components/cmp_websocket_server/
errors.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#[derive(Debug, thiserror::Error)]
pub enum Error {
    #[error("{0}")]
    Tungstenite(#[from] tokio_tungstenite::tungstenite::Error),

    #[error("Error bind to port: {0}")]
    BindToPort(std::io::Error),

    #[error("{0}")]
    TokioTaskJoin(#[from] tokio::task::JoinError),

    #[error("{0}")]
    TokioSyncMpsc(String),

    #[error("{0}")]
    FnInput(anyhow::Error),

    #[error("Error: {err}, text from client: {data}")]
    FnOutput { err: anyhow::Error, data: String },

    #[error("Client disconnected")]
    ClientDisconnected,

    #[error(transparent)]
    CmpOutput(crate::executor::ComponentError),
}

impl<TMsg> From<tokio::sync::mpsc::error::SendError<TMsg>> for Error {
    fn from(value: tokio::sync::mpsc::error::SendError<TMsg>) -> Self {
        Self::TokioSyncMpsc(value.to_string())
    }
}