ErrorCode enum variants to be more descriptive

This commit is contained in:
Josh Leeb-du Toit 2018-10-03 23:27:53 +10:00 committed by David Peter
parent 8bdd8f8e8f
commit cb1cfa108b
3 changed files with 7 additions and 7 deletions

View File

@ -1,13 +1,13 @@
pub enum ExitCode {
Error,
Sigint,
GeneralError,
KilledBySigint,
}
impl Into<i32> for ExitCode {
fn into(self) -> i32 {
match self {
ExitCode::Error => 1,
ExitCode::Sigint => 130,
ExitCode::GeneralError => 1,
ExitCode::KilledBySigint => 130,
}
}
}

View File

@ -45,7 +45,7 @@ pub fn print_entry(entry: &PathBuf, config: &FdOptions, wants_to_quit: &Arc<Atom
if r.is_err() {
// Probably a broken pipe. Exit gracefully.
process::exit(ExitCode::Error.into());
process::exit(ExitCode::GeneralError.into());
}
}
@ -87,7 +87,7 @@ fn print_entry_colorized(
if wants_to_quit.load(Ordering::Relaxed) {
write!(handle, "\n")?;
process::exit(ExitCode::Sigint.into());
process::exit(ExitCode::KilledBySigint.into());
}
}

View File

@ -319,6 +319,6 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<FdOptions>) {
receiver_thread.join().unwrap();
if wants_to_quit.load(Ordering::Relaxed) {
process::exit(ExitCode::Sigint.into());
process::exit(ExitCode::KilledBySigint.into());
}
}