Skip to content

Commit

Permalink
cli: improve panic messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Feb 3, 2025
1 parent 889da7c commit dd2b5ab
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,22 @@ pub mod args;
pub mod cmd;
mod exec;

use std::fmt::Display;
use std::panic::set_hook;

use clap::Parser;

use crate::args::Args;

fn main() -> anyhow::Result<()> { Args::parse().exec() }
fn main() -> anyhow::Result<()> {
set_hook(Box::new(|info| {
if let Some(error) = info.payload().downcast_ref::<&dyn Display>() {
eprintln!("Error: {error}");
eprintln!("Caused by:");
} else {
eprintln!("Error: {:?}", info);
}
eprintln!("{:?}", info);
}));
Args::parse().exec()
}

0 comments on commit dd2b5ab

Please sign in to comment.