diff --git a/ctru-rs/examples/audio-filters.rs b/ctru-rs/examples/audio-filters.rs index 75941b7..1dfde5a 100644 --- a/ctru-rs/examples/audio-filters.rs +++ b/ctru-rs/examples/audio-filters.rs @@ -40,8 +40,6 @@ fn fill_buffer(audio_data: &mut [u8], frequency: f32) { } fn main() { - ctru::use_panic_handler(); - let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); let mut hid = Hid::new().expect("Couldn't obtain HID controller"); let apt = Apt::new().expect("Couldn't obtain APT controller"); diff --git a/ctru-rs/examples/buttons.rs b/ctru-rs/examples/buttons.rs index 90862bf..258a715 100644 --- a/ctru-rs/examples/buttons.rs +++ b/ctru-rs/examples/buttons.rs @@ -5,8 +5,6 @@ use ctru::prelude::*; fn main() { - ctru::use_panic_handler(); - let apt = Apt::new().unwrap(); let mut hid = Hid::new().unwrap(); let gfx = Gfx::new().unwrap(); diff --git a/ctru-rs/examples/camera-image.rs b/ctru-rs/examples/camera-image.rs index 0c73f92..4084f21 100644 --- a/ctru-rs/examples/camera-image.rs +++ b/ctru-rs/examples/camera-image.rs @@ -14,8 +14,6 @@ use std::time::Duration; const WAIT_TIMEOUT: Duration = Duration::from_millis(300); fn main() { - ctru::use_panic_handler(); - let apt = Apt::new().expect("Failed to initialize Apt service."); let mut hid = Hid::new().expect("Failed to initialize Hid service."); let gfx = Gfx::new().expect("Failed to initialize GFX service."); diff --git a/ctru-rs/examples/file-explorer.rs b/ctru-rs/examples/file-explorer.rs index 6fa1183..3ad37c9 100644 --- a/ctru-rs/examples/file-explorer.rs +++ b/ctru-rs/examples/file-explorer.rs @@ -11,8 +11,6 @@ use std::os::horizon::fs::MetadataExt; use std::path::{Path, PathBuf}; fn main() { - ctru::use_panic_handler(); - let apt = Apt::new().unwrap(); let mut hid = Hid::new().unwrap(); let gfx = Gfx::new().unwrap(); diff --git a/ctru-rs/examples/futures-basic.rs b/ctru-rs/examples/futures-basic.rs index c41245c..5eb1c2a 100644 --- a/ctru-rs/examples/futures-basic.rs +++ b/ctru-rs/examples/futures-basic.rs @@ -13,8 +13,6 @@ use futures::StreamExt; use std::os::horizon::thread::BuilderExt; fn main() { - ctru::use_panic_handler(); - let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); let mut hid = Hid::new().expect("Couldn't obtain HID controller"); let apt = Apt::new().expect("Couldn't obtain APT controller"); diff --git a/ctru-rs/examples/futures-tokio.rs b/ctru-rs/examples/futures-tokio.rs index 986e930..06a7cff 100644 --- a/ctru-rs/examples/futures-tokio.rs +++ b/ctru-rs/examples/futures-tokio.rs @@ -6,8 +6,6 @@ use std::os::horizon::thread::BuilderExt; use std::time::Duration; fn main() { - ctru::use_panic_handler(); - let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); let mut hid = Hid::new().expect("Couldn't obtain HID controller"); let apt = Apt::new().expect("Couldn't obtain APT controller"); diff --git a/ctru-rs/examples/gfx-3d-mode.rs b/ctru-rs/examples/gfx-3d-mode.rs index 7176085..a5f3b1c 100644 --- a/ctru-rs/examples/gfx-3d-mode.rs +++ b/ctru-rs/examples/gfx-3d-mode.rs @@ -17,8 +17,6 @@ const IMAGE: &[u8] = include_bytes!("assets/ferris.rgb"); static ZERO: &[u8] = &[0; IMAGE.len()]; fn main() { - ctru::use_panic_handler(); - let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); let mut hid = Hid::new().expect("Couldn't obtain HID controller"); let apt = Apt::new().expect("Couldn't obtain APT controller"); diff --git a/ctru-rs/examples/gfx-bitmap.rs b/ctru-rs/examples/gfx-bitmap.rs index 8efb2be..e775d8e 100644 --- a/ctru-rs/examples/gfx-bitmap.rs +++ b/ctru-rs/examples/gfx-bitmap.rs @@ -18,8 +18,6 @@ use ctru::services::gfx::{Flush, Screen, Swap}; static IMAGE: &[u8] = include_bytes!("assets/ferris.rgb"); fn main() { - ctru::use_panic_handler(); - let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); let mut hid = Hid::new().expect("Couldn't obtain HID controller"); let apt = Apt::new().expect("Couldn't obtain APT controller"); diff --git a/ctru-rs/examples/gfx-wide-mode.rs b/ctru-rs/examples/gfx-wide-mode.rs index 109169d..5cae138 100644 --- a/ctru-rs/examples/gfx-wide-mode.rs +++ b/ctru-rs/examples/gfx-wide-mode.rs @@ -8,8 +8,6 @@ use ctru::prelude::*; fn main() { - ctru::use_panic_handler(); - let apt = Apt::new().unwrap(); let mut hid = Hid::new().unwrap(); let gfx = Gfx::new().unwrap(); diff --git a/ctru-rs/examples/hashmaps.rs b/ctru-rs/examples/hashmaps.rs index e563068..97f42ae 100644 --- a/ctru-rs/examples/hashmaps.rs +++ b/ctru-rs/examples/hashmaps.rs @@ -9,8 +9,6 @@ use ctru::prelude::*; fn main() { - ctru::use_panic_handler(); - // HashMaps generate hashes thanks to the 3DS' cryptografically secure generator. // This generator is only active when activating the `PS` service. // This service is automatically initialized. diff --git a/ctru-rs/examples/hello-both-screens.rs b/ctru-rs/examples/hello-both-screens.rs index 1f2b383..d7dc798 100644 --- a/ctru-rs/examples/hello-both-screens.rs +++ b/ctru-rs/examples/hello-both-screens.rs @@ -5,8 +5,6 @@ use ctru::prelude::*; fn main() { - ctru::use_panic_handler(); - let apt = Apt::new().unwrap(); let mut hid = Hid::new().unwrap(); let gfx = Gfx::new().unwrap(); diff --git a/ctru-rs/examples/hello-world.rs b/ctru-rs/examples/hello-world.rs index 9210484..cab15f3 100644 --- a/ctru-rs/examples/hello-world.rs +++ b/ctru-rs/examples/hello-world.rs @@ -8,7 +8,6 @@ use std::io::BufWriter; fn main() { // Setup the custom panic handler in case any errors arise. // Thanks to it the user will get promptly notified of any panics. - ctru::use_panic_handler(); // Setup Graphics, Controller Inputs, Application runtime. // These is standard setup any app would need. diff --git a/ctru-rs/examples/linear-memory.rs b/ctru-rs/examples/linear-memory.rs index de653e6..8b386fb 100644 --- a/ctru-rs/examples/linear-memory.rs +++ b/ctru-rs/examples/linear-memory.rs @@ -10,8 +10,6 @@ use ctru::linear::LinearAllocator; use ctru::prelude::*; fn main() { - ctru::use_panic_handler(); - let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); let mut hid = Hid::new().expect("Couldn't obtain HID controller"); let apt = Apt::new().expect("Couldn't obtain APT controller"); diff --git a/ctru-rs/examples/mii-selector.rs b/ctru-rs/examples/mii-selector.rs index 2987970..3b2b0ef 100644 --- a/ctru-rs/examples/mii-selector.rs +++ b/ctru-rs/examples/mii-selector.rs @@ -6,8 +6,6 @@ use ctru::applets::mii_selector::{Error, MiiSelector, Options}; use ctru::prelude::*; fn main() { - ctru::use_panic_handler(); - let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); let mut hid = Hid::new().expect("Couldn't obtain HID controller"); let apt = Apt::new().expect("Couldn't obtain APT controller"); diff --git a/ctru-rs/examples/movement.rs b/ctru-rs/examples/movement.rs index fe5e764..af83488 100644 --- a/ctru-rs/examples/movement.rs +++ b/ctru-rs/examples/movement.rs @@ -5,8 +5,6 @@ use ctru::prelude::*; fn main() { - ctru::use_panic_handler(); - let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); let mut hid = Hid::new().expect("Couldn't obtain HID controller"); let apt = Apt::new().expect("Couldn't obtain APT controller"); diff --git a/ctru-rs/examples/network-sockets.rs b/ctru-rs/examples/network-sockets.rs index d55e29c..9689500 100644 --- a/ctru-rs/examples/network-sockets.rs +++ b/ctru-rs/examples/network-sockets.rs @@ -9,8 +9,6 @@ use std::net::{Shutdown, TcpListener}; use std::time::Duration; fn main() { - ctru::use_panic_handler(); - let gfx = Gfx::new().unwrap(); let mut hid = Hid::new().unwrap(); let apt = Apt::new().unwrap(); diff --git a/ctru-rs/examples/output-3dslink.rs b/ctru-rs/examples/output-3dslink.rs index 9df3f3d..fb1194a 100644 --- a/ctru-rs/examples/output-3dslink.rs +++ b/ctru-rs/examples/output-3dslink.rs @@ -13,8 +13,6 @@ use ctru::prelude::*; fn main() { - ctru::use_panic_handler(); - let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); let mut hid = Hid::new().expect("Couldn't obtain HID controller"); let apt = Apt::new().expect("Couldn't obtain APT controller"); diff --git a/ctru-rs/examples/romfs.rs b/ctru-rs/examples/romfs.rs index 490a785..e9c7f04 100644 --- a/ctru-rs/examples/romfs.rs +++ b/ctru-rs/examples/romfs.rs @@ -5,8 +5,6 @@ use ctru::prelude::*; fn main() { - ctru::use_panic_handler(); - let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); let mut hid = Hid::new().expect("Couldn't obtain HID controller"); let apt = Apt::new().expect("Couldn't obtain APT controller"); diff --git a/ctru-rs/examples/software-keyboard.rs b/ctru-rs/examples/software-keyboard.rs index e754781..61c32db 100644 --- a/ctru-rs/examples/software-keyboard.rs +++ b/ctru-rs/examples/software-keyboard.rs @@ -6,8 +6,6 @@ use ctru::applets::swkbd::{Button, SoftwareKeyboard}; use ctru::prelude::*; fn main() { - ctru::use_panic_handler(); - let apt = Apt::new().unwrap(); let mut hid = Hid::new().unwrap(); let gfx = Gfx::new().unwrap(); diff --git a/ctru-rs/examples/system-configuration.rs b/ctru-rs/examples/system-configuration.rs index f1748f7..6060066 100644 --- a/ctru-rs/examples/system-configuration.rs +++ b/ctru-rs/examples/system-configuration.rs @@ -7,8 +7,6 @@ use ctru::prelude::*; use ctru::services::cfgu::Cfgu; fn main() { - ctru::use_panic_handler(); - let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); let mut hid = Hid::new().expect("Couldn't obtain HID controller"); let apt = Apt::new().expect("Couldn't obtain APT controller"); diff --git a/ctru-rs/examples/thread-basic.rs b/ctru-rs/examples/thread-basic.rs index 3e4604b..58474ba 100644 --- a/ctru-rs/examples/thread-basic.rs +++ b/ctru-rs/examples/thread-basic.rs @@ -6,8 +6,6 @@ use std::os::horizon::thread::BuilderExt; use std::time::Duration; fn main() { - ctru::use_panic_handler(); - let apt = Apt::new().unwrap(); let mut hid = Hid::new().unwrap(); let gfx = Gfx::new().unwrap(); diff --git a/ctru-rs/examples/thread-info.rs b/ctru-rs/examples/thread-info.rs index 46d34d3..4069bc3 100644 --- a/ctru-rs/examples/thread-info.rs +++ b/ctru-rs/examples/thread-info.rs @@ -7,8 +7,6 @@ use ctru::prelude::*; use std::os::horizon::thread::BuilderExt; fn main() { - ctru::use_panic_handler(); - let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); let mut hid = Hid::new().expect("Couldn't obtain HID controller"); let apt = Apt::new().expect("Couldn't obtain APT controller"); diff --git a/ctru-rs/examples/thread-locals.rs b/ctru-rs/examples/thread-locals.rs index 72458c9..50e24a3 100644 --- a/ctru-rs/examples/thread-locals.rs +++ b/ctru-rs/examples/thread-locals.rs @@ -10,8 +10,6 @@ std::thread_local! { } fn main() { - ctru::use_panic_handler(); - let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); gfx.top_screen.borrow_mut().set_wide_mode(true); let mut hid = Hid::new().expect("Couldn't obtain HID controller"); diff --git a/ctru-rs/examples/time-rtc.rs b/ctru-rs/examples/time-rtc.rs index ca4709a..f05cd64 100644 --- a/ctru-rs/examples/time-rtc.rs +++ b/ctru-rs/examples/time-rtc.rs @@ -6,8 +6,6 @@ use ctru::prelude::*; fn main() { - ctru::use_panic_handler(); - let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); let mut hid = Hid::new().expect("Couldn't obtain HID controller"); let apt = Apt::new().expect("Couldn't obtain APT controller"); diff --git a/ctru-rs/examples/title-info.rs b/ctru-rs/examples/title-info.rs index 4332750..03fe08f 100644 --- a/ctru-rs/examples/title-info.rs +++ b/ctru-rs/examples/title-info.rs @@ -8,8 +8,6 @@ use ctru::services::am::Am; use ctru::services::fs::FsMediaType; fn main() { - ctru::use_panic_handler(); - let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); let mut hid = Hid::new().expect("Couldn't obtain HID controller"); let apt = Apt::new().expect("Couldn't obtain APT controller"); diff --git a/ctru-rs/examples/touch-screen.rs b/ctru-rs/examples/touch-screen.rs index fe2409d..8475eac 100644 --- a/ctru-rs/examples/touch-screen.rs +++ b/ctru-rs/examples/touch-screen.rs @@ -5,8 +5,6 @@ use ctru::prelude::*; fn main() { - ctru::use_panic_handler(); - let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); let mut hid = Hid::new().expect("Couldn't obtain HID controller"); let apt = Apt::new().expect("Couldn't obtain APT controller"); diff --git a/ctru-rs/src/console.rs b/ctru-rs/src/console.rs index 5c9fba1..5a8c772 100644 --- a/ctru-rs/src/console.rs +++ b/ctru-rs/src/console.rs @@ -117,9 +117,6 @@ impl<'screen> Console<'screen> { /// This function is used to check whether one of the two screens has an existing (and selected) [`Console`], /// so that the program can be sure its output will be shown *somewhere*. /// - /// The main use of this is within the [`ctru::use_panic_handler()`](crate::use_panic_handler()) hook, - /// since it will only stop the program's execution if the user is able to see the panic information output on screen. - /// /// # Example /// /// ``` diff --git a/ctru-rs/src/lib.rs b/ctru-rs/src/lib.rs index f1569bb..58537ee 100644 --- a/ctru-rs/src/lib.rs +++ b/ctru-rs/src/lib.rs @@ -56,45 +56,6 @@ macro_rules! from_impl { }; } -/// Activate the custom [`ctru-rs`](crate) panic handler. -/// -/// With this implementation, the main thread will stop and try to print debug info to an available [`Console`](console::Console). -/// In case it fails to find an active [`Console`](console::Console) the program will just exit. -/// -/// # Notes -/// -/// When `test` is enabled, this function will not do anything, as its behaviour should be overridden by the `test` environment. -pub fn use_panic_handler() { - #[cfg(not(test))] - panic_hook_setup(); -} - -/// Internal protocol to activate the custom panic handler hook. -/// -/// # Notes -/// -/// When `test` is enabled, this function will be ignored. -#[cfg(not(test))] -fn panic_hook_setup() { - use std::panic::PanicInfo; - - let main_thread = std::thread::current().id(); - - // Panic Hook setup - let default_hook = std::panic::take_hook(); - let new_hook = Box::new(move |info: &PanicInfo| { - default_hook(info); - - // Only for panics in the main thread - if main_thread == std::thread::current().id() && console::Console::exists() { - println!("\nThe software will exit in 5 seconds"); - - std::thread::sleep(std::time::Duration::from_secs(5)); - } - }); - std::panic::set_hook(new_hook); -} - pub mod applets; pub mod console; pub mod error;