chiral-cli-common 0.1.2

Common Types, Traits and Structs for Chiral Command-Line-Interface
Documentation
//! 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);
    }
}