From c166df7858544e6509f772fc423fb168fb98fe0a Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 3 May 2025 18:21:32 -0400 Subject: [PATCH] Emit file and line info in panics if available --- src/lib.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 4513fd9..2f250aa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -437,7 +437,15 @@ fn main() { "Unknown error".to_string() }; - show_message(&format!("Error: {s}")); + if let Some(location) = panic_hook_info.location() { + show_message(&format!( + "Error: {s} in file '{}' at line {}", + location.file(), + location.line() + )); + } else { + show_message(&format!("Error: {s}")); + } })); let current_exe = std::env::current_exe().expect("Failed to get executable path");