|
|
@ -76,17 +76,17 @@ fn main() { |
|
|
|
};
|
|
|
|
|
|
|
|
if let Err(ref e) = app::main(opts) {
|
|
|
|
use std::io::prelude::*;
|
|
|
|
let stderr = std::io::stderr();
|
|
|
|
let mut lock = stderr.lock();
|
|
|
|
// Write the top-level error message, then chained errors, then backtrace if available
|
|
|
|
error!("error: {}", e);
|
|
|
|
writeln!(lock, "error: {}", e).expect("error while writing error");
|
|
|
|
for e in e.iter().skip(1) {
|
|
|
|
error!("caused by: {}", e);
|
|
|
|
writeln!(lock, "caused by: {}", e).expect("error while writing error");
|
|
|
|
}
|
|
|
|
if let Some(backtrace) = e.backtrace() {
|
|
|
|
error!("backtrace: {:?}", backtrace);
|
|
|
|
writeln!(lock, "backtrace: {:?}", backtrace).expect("error while writing error");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Exit with a nonzero exit code
|
|
|
|
// TODO: Decide how to allow code to set this to something other than 1
|
|
|
|
std::process::exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|