mirror of
https://github.com/sharkdp/fd
synced 2024-09-15 22:20:45 +00:00
ErrorCode enum variants to be more descriptive
This commit is contained in:
parent
8bdd8f8e8f
commit
cb1cfa108b
|
@ -1,13 +1,13 @@
|
||||||
pub enum ExitCode {
|
pub enum ExitCode {
|
||||||
Error,
|
GeneralError,
|
||||||
Sigint,
|
KilledBySigint,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<i32> for ExitCode {
|
impl Into<i32> for ExitCode {
|
||||||
fn into(self) -> i32 {
|
fn into(self) -> i32 {
|
||||||
match self {
|
match self {
|
||||||
ExitCode::Error => 1,
|
ExitCode::GeneralError => 1,
|
||||||
ExitCode::Sigint => 130,
|
ExitCode::KilledBySigint => 130,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ pub fn print_entry(entry: &PathBuf, config: &FdOptions, wants_to_quit: &Arc<Atom
|
||||||
|
|
||||||
if r.is_err() {
|
if r.is_err() {
|
||||||
// Probably a broken pipe. Exit gracefully.
|
// 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) {
|
if wants_to_quit.load(Ordering::Relaxed) {
|
||||||
write!(handle, "\n")?;
|
write!(handle, "\n")?;
|
||||||
process::exit(ExitCode::Sigint.into());
|
process::exit(ExitCode::KilledBySigint.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -319,6 +319,6 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<FdOptions>) {
|
||||||
receiver_thread.join().unwrap();
|
receiver_thread.join().unwrap();
|
||||||
|
|
||||||
if wants_to_quit.load(Ordering::Relaxed) {
|
if wants_to_quit.load(Ordering::Relaxed) {
|
||||||
process::exit(ExitCode::Sigint.into());
|
process::exit(ExitCode::KilledBySigint.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue