mirror of
https://github.com/sharkdp/hexyl.git
synced 2026-10-28 08:05:52 +00:00
Handle clap errors and other errors separately
This commit is contained in:
1 parent
866feb2966
commit
92c974d066
1 file changed
+7
-4
+7
-4
@@ -270,9 +270,12 @@ fn main() {
|
|||||||
let result = run();
|
let result = run();
|
||||||
|
|
||||||
if let Err(err) = result {
|
if let Err(err) = result {
|
||||||
// The whitespace is being removed from the right because
|
if let Some(clap_err) = err.downcast_ref::<clap::Error>() {
|
||||||
// clap errors add a newline to the end of the output already
|
eprint!("{}", clap_err); // Clap errors already have newlines
|
||||||
eprintln!("Error: {}", format!("{}", err).trim_right());
|
std::process::exit(1);
|
||||||
std::process::exit(1);
|
} else {
|
||||||
|
eprintln!("Error: {}", err);
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user