Skip to content

Commit 60477da

Browse files
authored
Merge pull request #9 from Spxg/main
panic_handler: update msg format and add column location
2 parents d302a0d + a1cda4a commit 60477da

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

os/src/lang_items.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ use crate::sbi::shutdown;
33

44
#[panic_handler]
55
fn panic(info: &PanicInfo) -> ! {
6-
if let Some(location) = info.location() {
7-
println!("[kernel] Panicked at {}:{} {}", location.file(), location.line(), info.message().unwrap());
8-
} else {
9-
println!("[kernel] Panicked: {}", info.message().unwrap());
6+
match info.location() {
7+
Some(location) => {
8+
println!("[kernel] panicked at '{}', {}:{}:{}",
9+
info.message().unwrap(),
10+
location.file(),
11+
location.line(),
12+
location.column()
13+
);
14+
}
15+
None => println!("[kernel] panicked at '{}'", info.message().unwrap())
1016
}
1117
shutdown()
1218
}

0 commit comments

Comments
 (0)