summaryrefslogtreecommitdiffstats
path: root/sm/plugins/tedge_apama_plugin/src/error.rs
blob: 0e32850cb4a702e27fe19eb3c8d6cb6f3deb6c25 (plain)
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
#[derive(thiserror::Error, Debug)]
pub enum InternalError {
    #[error("Fail to run `{cmd}`: {from}")]
    ExecError { cmd: String, from: std::io::Error },

    #[error(transparent)]
    FromIo(#[from] std::io::Error),

    #[error(transparent)]
    FromUtf8(#[from] std::string::FromUtf8Error),

    #[error(transparent)]
    FromZipError(#[from] zip::result::ZipError),

    #[error("Apama not installed at /opt/softwareag/Apama")]
    ApamaNotInstalled,
}

impl InternalError {
    pub fn exec_error(cmd: impl Into<String>, from: std::io::Error) -> InternalError {
        InternalError::ExecError {
            cmd: cmd.into(),
            from,
        }
    }
}