Handle clap errors and other errors separately

This commit is contained in:
arnavb11 authored and David Peter committed 2019-01-13 18:03:07 +01:00
1 parent 866feb2966
commit 92c974d066
1 file changed
+7 -4
+7 -4
View File
@@ -270,9 +270,12 @@ fn main() {
let result = run();
if let Err(err) = result {
// The whitespace is being removed from the right because
// clap errors add a newline to the end of the output already
eprintln!("Error: {}", format!("{}", err).trim_right());
std::process::exit(1);
if let Some(clap_err) = err.downcast_ref::<clap::Error>() {
eprint!("{}", clap_err); // Clap errors already have newlines
std::process::exit(1);
} else {
eprintln!("Error: {}", err);
std::process::exit(1);
}
}
}