From 77549d7bbcdb64e5e0dc5dd7a637cef6ae447ce7 Mon Sep 17 00:00:00 2001 From: Y0ba <1163958+Y0ba@users.noreply.github.com> Date: Sun, 5 Jun 2022 19:42:15 +0000 Subject: [PATCH] Catch panics in child threads (#635) --- src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main.rs b/src/main.rs index dd941ca..030914a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,13 @@ use av1an_cli::run; +use std::panic; +use std::process; fn main() -> anyhow::Result<()> { + let orig_hook = panic::take_hook(); + // Catch panics in child threads + panic::set_hook(Box::new(move |panic_info| { + orig_hook(panic_info); + process::exit(1); + })); run() }