mirror of
https://github.com/LearningOS/rust-based-os-comp2022.git
synced 2026-02-12 14:45:13 +08:00
30 lines
669 B
Rust
30 lines
669 B
Rust
//! The panic handler
|
|
|
|
use crate::console::ANSICON;
|
|
use crate::sbi::shutdown;
|
|
|
|
use core::panic::PanicInfo;
|
|
|
|
#[panic_handler]
|
|
/// panic handler
|
|
fn panic(info: &PanicInfo) -> ! {
|
|
if let Some(location) = info.location() {
|
|
println_colorized!(
|
|
"[kernel] Panicked at {}:{} {}",
|
|
ANSICON::FgRed,
|
|
ANSICON::BgDefault,
|
|
location.file(),
|
|
location.line(),
|
|
info.message().unwrap()
|
|
);
|
|
} else {
|
|
println_colorized!(
|
|
"[kernel] Panicked: {}",
|
|
ANSICON::FgRed,
|
|
ANSICON::BgDefault,
|
|
info.message().unwrap()
|
|
);
|
|
}
|
|
shutdown()
|
|
}
|