From 4ce6784b08ec8a1238ed37b7a3ac695d289ad8a4 Mon Sep 17 00:00:00 2001 From: mrMiiao <90341146+mrMiiao@users.noreply.github.com> Date: Thu, 11 Aug 2022 16:26:45 +0300 Subject: [PATCH] Custom panic --- src/main.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main.rs b/src/main.rs index 48e1310..644a609 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,15 @@ mod interpreter; use interpreter::Interpreter; fn main() { + std::panic::set_hook( + box |info| { + eprint!("{msg}", msg = match info.message() { + None => "Program panicked!".to_owned(), + Some(x) => x.to_string() + }); + } + ); + let start = Instant::now(); let args = Args::parse();