flipperzero_rt/
panic_handler.rsuse core::ffi::c_char;
use core::panic::PanicInfo;
use flipperzero_sys as sys;
#[panic_handler]
pub fn panic(panic_info: &PanicInfo<'_>) -> ! {
unsafe {
let thread_id = sys::furi_thread_get_current_id();
let thread_name = if !thread_id.is_null() {
sys::furi_thread_get_name(thread_id)
} else {
c"unknown".as_ptr()
};
sys::__wrap_printf(c"\x1b[0;31mthread: '%s' paniced".as_ptr(), thread_name);
if let Some(s) = panic_info.message().as_str() {
sys::__wrap_printf(c" at '%*s'".as_ptr(), s.len(), s.as_ptr() as *const c_char);
}
if let Some(location) = panic_info.location() {
let file = location.file();
let line = location.line();
sys::__wrap_printf(
c", %*s:%u".as_ptr(),
file.len(),
file.as_ptr() as *const c_char,
line,
);
}
sys::__wrap_printf(c"\x1b[0m\r\n".as_ptr());
sys::furi_thread_stdout_flush();
sys::furi_thread_yield(); sys::crash!("Rust panic")
}
}