cdk_common/pub_sub/
error.rs

1//! Error types for the pub-sub module.
2
3use tokio::sync::mpsc::error::TrySendError;
4
5#[derive(thiserror::Error, Debug)]
6/// Error
7pub enum Error {
8    /// No subscription found
9    #[error("Subscription not found")]
10    NoSubscription,
11
12    /// Parsing error
13    #[error("Parsing Error {0}")]
14    ParsingError(String),
15
16    /// Internal error
17    #[error("Internal")]
18    Internal(Box<dyn std::error::Error + Send + Sync>),
19
20    /// Internal error
21    #[error("Internal error {0}")]
22    InternalStr(String),
23
24    /// Not supported
25    #[error("Not supported")]
26    NotSupported,
27
28    /// Channel is full
29    #[error("Channel is full")]
30    ChannelFull,
31
32    /// Channel is closed
33    #[error("Channel is close")]
34    ChannelClosed,
35}
36
37impl<T> From<TrySendError<T>> for Error {
38    fn from(value: TrySendError<T>) -> Self {
39        match value {
40            TrySendError::Closed(_) => Error::ChannelClosed,
41            TrySendError::Full(_) => Error::ChannelFull,
42        }
43    }
44}