Chapter1: Update panic_handler.

This commit is contained in:
Yifan Wu 2020-11-13 12:06:39 +08:00
parent 6a96d7d122
commit d2c0be3dd0
2 changed files with 25 additions and 6 deletions

View file

@ -1,6 +1,12 @@
use core::panic::PanicInfo;
use crate::sbi::shutdown;
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
fn panic(info: &PanicInfo) -> ! {
if let Some(location) = info.location() {
println!("Panicked at {}:{} {}", location.file(), location.line(), info.message().unwrap());
} else {
println!("Panicked: {}", info.message().unwrap());
}
shutdown()
}