Skip to content

Commit

Permalink
Add backtrace to panic_hook function
Browse files Browse the repository at this point in the history
  • Loading branch information
deepu105 committed Jan 25, 2024
1 parent d08b126 commit e31fc1b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,18 +299,20 @@ fn panic_hook(info: &PanicInfo<'_>) {

#[cfg(not(debug_assertions))]
fn panic_hook(info: &PanicInfo<'_>) {
use backtrace::Backtrace;
use crossterm::style::Print;
use human_panic::{handle_dump, print_msg, Metadata};
use log::error;

let meta = Metadata {
version: env!("CARGO_PKG_VERSION").into(),
name: env!("CARGO_PKG_NAME").into(),
authors: env!("CARGO_PKG_AUTHORS").replace(":", ", ").into(),
authors: env!("CARGO_PKG_AUTHORS").replace(':', ", ").into(),
homepage: env!("CARGO_PKG_HOMEPAGE").into(),
};
let file_path = handle_dump(&meta, info);
let (msg, location) = get_panic_info(info);
let stacktrace: String = format!("{:?}", Backtrace::new()).replace('\n', "\n\r");

error!(
"thread '<unnamed>' panicked at '{}', {}\n\r{}",
Expand Down

0 comments on commit e31fc1b

Please sign in to comment.