rkgk/crates/haku-wasm/src/panicking.rs

21 lines
432 B
Rust
Raw Normal View History

2024-08-10 23:10:03 +02:00
use core::fmt::Write;
use alloc::string::String;
extern "C" {
fn panic(message_len: u32, message: *const u8) -> !;
}
fn panic_impl(info: &core::panic::PanicInfo) -> ! {
let mut message = String::new();
_ = write!(&mut message, "{info}");
unsafe { panic(message.len() as u32, message.as_ptr()) };
}
#[cfg(not(test))]
#[panic_handler]
fn panic_handler(info: &core::panic::PanicInfo) -> ! {
panic_impl(info)
}