diff --git a/src/main.rs b/src/main.rs index 352df81..021f452 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,7 @@ enum Commands { Config(command::config::Commands), } -fn main() -> Result<(), command::Error> { +fn run() -> Result<(), command::Error> { let args = Args::parse(); match args.command { @@ -30,3 +30,22 @@ fn main() -> Result<(), command::Error> { 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); + } +}