Skip to content

Commit

Permalink
panic hook
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsteyk committed Jan 1, 2022
1 parent f18da87 commit 9e5c89e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ fn get_ooa_hash(data: &[u8]) -> Option<[u8; 20]> {
}

fn main() {
// Nicer Release error messages, I guess?
#[cfg(not(debug_assertions))]
std::panic::set_hook(Box::new(|panic_info: &std::panic::PanicInfo| {
if let Some(s) = panic_info.payload().downcast_ref::<&str>() {
println!("{}", s);
} else {
let string = panic_info.to_string();
println!(
"{}",
&string[13..string.rfind('\'').unwrap_or(string.len())]
);
}
}));

let file = std::env::args().nth(1);
// let key = std::env::args().nth(2);
if let Some(path) = file {
Expand Down

0 comments on commit 9e5c89e

Please sign in to comment.