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
33
34
35
36
//! Errors

#[derive(PartialEq, Debug)]
pub enum CommandLineError {
    JobIDNotFound(String),
    ReportNotFound(String)
}

impl std::error::Error for CommandLineError {
    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
        match *self {
            Self::JobIDNotFound(_) => None,
            Self::ReportNotFound(_) => None,
        }
    }
}

impl std::fmt::Display for CommandLineError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::JobIDNotFound(prefix) => format!("JobID with prefix '{prefix}' not found").fmt(f),
            Self::ReportNotFound(prefix) => format!("Report with JobID prefix '{prefix}' not found").fmt(f)
        }
    }
}

error_chain::error_chain! {
    foreign_links {
        Io(std::io::Error);
        HttpRequest(reqwest::Error);
        Strum(strum::ParseError);
        Rustyline(rustyline::error::ReadlineError);
        FingerprintKindConversion(chiral_common::kinds::FingerprintKindConversionError);
        CommandLine(CommandLineError);
    }
}