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
#[derive(Debug, thiserror::Error)]
pub enum Error {
    #[error("{0}")]
    InteractiveError(#[from] clashctl_interactive::Error),

    #[error("Clashctl error: {0}")]
    ClashCtl(#[from] crate::clashctl::Error),

    #[error("TUI error")]
    TuiError(#[from] std::io::Error),

    #[error("TUI backend error")]
    TuiBackendErr,

    #[error("TUI interuptted error")]
    TuiInterupttedErr,

    #[error("TUI internal error")]
    TuiInternalErr,

    #[error("Set logger error ({0})")]
    SetLoggerError(#[from] log::SetLoggerError),
}

impl<T> From<std::sync::mpsc::SendError<T>> for Error {
    fn from(_: std::sync::mpsc::SendError<T>) -> Self {
        Self::TuiBackendErr
    }
}

pub type Result<T> = std::result::Result<T, Error>;