From d630c25926b194563807f458afb3344b859771f2 Mon Sep 17 00:00:00 2001 From: Fenrir Date: Sun, 25 Feb 2024 17:53:12 -0700 Subject: [PATCH] Check for APT init errors in panic hook --- ctru-rs/src/applets/error.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ctru-rs/src/applets/error.rs b/ctru-rs/src/applets/error.rs index b723aa8..92dc7e3 100644 --- a/ctru-rs/src/applets/error.rs +++ b/ctru-rs/src/applets/error.rs @@ -100,15 +100,13 @@ pub fn set_panic_hook(use_stderr: bool) { use std::sync::TryLockError; std::panic::set_hook(Box::new(move |panic_info| { - let _apt = Apt::new(); - let thread = std::thread::current(); let name = thread.name().unwrap_or(""); // If we get a `WouldBlock` error, we know that the `Gfx` service has been initialized. // Otherwise fallback to printing over stderr. - if let Err(TryLockError::WouldBlock) = GFX_ACTIVE.try_lock() { + if let (Err(TryLockError::WouldBlock), Ok(_apt)) = (GFX_ACTIVE.try_lock(), Apt::new()) { if use_stderr { print_to_stderr(name, panic_info); }