print error chain
This commit is contained in:
parent
9c248168b4
commit
5c515f6d87
1 changed files with 20 additions and 1 deletions
21
src/main.rs
21
src/main.rs
|
@ -20,7 +20,7 @@ enum Commands {
|
||||||
Config(command::config::Commands),
|
Config(command::config::Commands),
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), command::Error> {
|
fn run() -> Result<(), command::Error> {
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
|
||||||
match args.command {
|
match args.command {
|
||||||
|
@ -30,3 +30,22 @@ fn main() -> Result<(), command::Error> {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let res = run();
|
||||||
|
|
||||||
|
if let Err(err) = res {
|
||||||
|
println!("An error occurred!");
|
||||||
|
println!(" raw: {:?}", err);
|
||||||
|
println!(" message: {}", err);
|
||||||
|
|
||||||
|
let mut err: &dyn std::error::Error = &err;
|
||||||
|
|
||||||
|
while let Some(src) = err.source() {
|
||||||
|
println!("caused by: {}", src);
|
||||||
|
err = src;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue