Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
Print informative panic message in release build
Browse files Browse the repository at this point in the history
  • Loading branch information
SamZhang3 committed Jun 10, 2023
1 parent c8c8e58 commit a0a6a13
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion kernel/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,23 @@ fn panic(panic_info: &PanicInfo) -> ! {
if let Some(mut locked_term) = TERMINAL.as_inner().try_lock() {
// The terminal may not yet be initialized.
if let Some(ref mut term) = &mut *locked_term {
let _ = core::fmt::write(term, format_args!("\x1B[1;31m{}\x1B[m", panic_info));
if !cfg!(debug_assertions) {
// Clear the screen
term.print("\x1B[H\x1B[2J");
}
term.print("\x1B[1;31m");
if !cfg!(debug_assertions) {
term.print(
"KERNEL PANIC\n\n\
A severe error has occurred in the Doors operating system and it has been shut \
down. If this is a reproducible or recurring issue, you may want to file a bug \
report at https://github.com/SamZhang3/doors-rs, with the below information and \
possibly other details regarding what actions trigger the problem.\n\n\
Technical details:",
);
}
let _ = core::fmt::write(term, format_args!("\n{}", panic_info));
term.print("\x1B[m");
}
}

Expand Down

0 comments on commit a0a6a13

Please sign in to comment.