Skip to content

Commit

Permalink
use if let in panic hook instead of match
Browse files Browse the repository at this point in the history
  • Loading branch information
FenrirWolf committed Feb 25, 2024
1 parent a67c8c0 commit a65b9ed
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions ctru-rs/src/applets/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,22 @@ pub fn set_panic_hook(use_stderr: bool) {

// If we get a `WouldBlock` error, we know that the `Gfx` service has been initialized.
// Otherwise fallback to printing over stderr.
match GFX_ACTIVE.try_lock() {
Err(TryLockError::WouldBlock) => {
if use_stderr {
print_to_stderr(name, panic_info);
}
if let Err(TryLockError::WouldBlock) = GFX_ACTIVE.try_lock() {
if use_stderr {
print_to_stderr(name, panic_info);
}

let payload = format!("thread '{name}' {panic_info}");
let payload = format!("thread '{name}' {panic_info}");

let mut popup = PopUp::new(Kind::Top);
let mut popup = PopUp::new(Kind::Top);

popup.set_text(&payload);
popup.set_text(&payload);

unsafe {
popup.launch_unchecked();
}
}
_ => {
print_to_stderr(name, panic_info);
unsafe {
popup.launch_unchecked();
}
} else {
print_to_stderr(name, panic_info);
}
}));

Expand Down

0 comments on commit a65b9ed

Please sign in to comment.