Skip to content

Commit aebe0d3

Browse files
committed
Write location first in panic handler
In case the formatted output fails for some reason.
1 parent e997c74 commit aebe0d3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

bios/stage-2/src/screen.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ impl Write for Writer {
3232
#[panic_handler]
3333
#[cfg(not(test))]
3434
pub fn panic(info: &core::panic::PanicInfo) -> ! {
35-
let _ = writeln!(Writer, "\nPANIC: {info}");
35+
let _ = write!(Writer, "\nPANIC: ");
36+
if let Some(location) = info.location() {
37+
let _ = writeln!(Writer, "{location} ");
38+
}
39+
let _ = writeln!(Writer, " {info}");
3640

3741
loop {
3842
unsafe {

0 commit comments

Comments
 (0)