bobcat_panic/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2
3#[cfg(feature = "alloc")]
4extern crate alloc;
5
6#[cfg(all(target_arch = "wasm32", feature = "console"))]
7mod wasm {
8    #[link(wasm_import_module = "vm_hooks")]
9    unsafe extern "C" {
10        pub(crate) fn log_txt(ptr: *const u8, len: usize);
11    }
12}
13
14#[cfg(all(not(feature = "std"), target_arch = "wasm32"))]
15#[panic_handler]
16pub fn panic_handler(_msg: &core::panic::PanicInfo) -> ! {
17    #[cfg(feature = "console")]
18    {
19        let msg = alloc::format!("{_msg}");
20        unsafe { wasm::log_txt(msg.as_ptr(), msg.len()) }
21    }
22    core::arch::wasm32::unreachable()
23}