diff --git a/Cargo.lock b/Cargo.lock index 4ae78b3..986a94f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1501,6 +1501,22 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" +[[package]] +name = "human-panic" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4f016c89920bbb30951a8405ecacbb4540db5524313b9445736e7e1855cf370" +dependencies = [ + "anstream", + "anstyle", + "backtrace", + "os_info", + "serde", + "serde_derive", + "toml 0.8.9", + "uuid", +] + [[package]] name = "humantime" version = "2.1.0" @@ -2217,6 +2233,17 @@ dependencies = [ "hashbrown 0.14.3", ] +[[package]] +name = "os_info" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "006e42d5b888366f1880eda20371fedde764ed2213dc8496f49622fa0c99cd5e" +dependencies = [ + "log", + "serde", + "winapi", +] + [[package]] name = "overload" version = "0.1.1" @@ -2855,6 +2882,7 @@ dependencies = [ "directories", "displaydoc", "gethostname", + "human-panic", "humantime", "indicatif", "itertools", diff --git a/Cargo.toml b/Cargo.toml index b4ba9fc..a5dfe24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,6 +80,7 @@ clap_complete = "4" dialoguer = "0.11.0" directories = "5" gethostname = "0.4" +human-panic = "1.2.3" humantime = "2" indicatif = "0.17" itertools = "0.12" diff --git a/src/commands.rs b/src/commands.rs index a74736a..bb4653c 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -53,6 +53,7 @@ use clap::builder::{ Styles, }; use dialoguer::Password; +use human_panic::setup_panic; use log::{log, Level}; use rustic_core::{OpenStatus, Repository}; use simplelog::{CombinedLogger, LevelFilter, TermLogger, TerminalMode, WriteLogger}; @@ -159,6 +160,9 @@ pub struct EntryPoint { impl Runnable for EntryPoint { fn run(&self) { + // Set up panic hook for better error messages and logs + setup_panic!(); + self.commands.run(); RUSTIC_APP.shutdown(Shutdown::Graceful) }