fd/src/exit_codes.rs

28 lines
581 B
Rust
Raw Normal View History

pub enum ExitCode {
Success,
GeneralError,
KilledBySigint,
}
impl Into<i32> for ExitCode {
fn into(self) -> i32 {
match self {
2020-02-22 08:55:32 +01:00
ExitCode::Success => 0,
ExitCode::GeneralError => 1,
ExitCode::KilledBySigint => 130,
}
}
}
impl ExitCode {
pub fn error_if_any_error(results: Vec<Self>) -> Self {
if results.iter().any(|s| match s {
2020-02-22 08:55:32 +01:00
ExitCode::GeneralError => true,
_ => false,
}) {
2020-02-22 08:55:32 +01:00
return ExitCode::GeneralError;
}
2020-02-22 08:55:32 +01:00
ExitCode::Success
}
}