diff --git a/rust_crate/src/interface_web.rs b/rust_crate/src/interface_web.rs index 22b9fd69..9e849056 100644 --- a/rust_crate/src/interface_web.rs +++ b/rust_crate/src/interface_web.rs @@ -22,12 +22,12 @@ where #[wasm_bindgen] extern "C" { - #[wasm_bindgen(js_namespace = rinf)] + #[wasm_bindgen(js_namespace = rinf, catch)] pub fn send_rust_signal_extern( resource: i32, message_bytes: Uint8Array, binary: Uint8Array, - ); + ) -> Result<(), JsValue>; // catch the JS exception } pub fn send_rust_signal_real( @@ -35,10 +35,15 @@ pub fn send_rust_signal_real( message_bytes: Vec, binary: Vec, ) -> Result<(), RinfError> { - send_rust_signal_extern( + match send_rust_signal_extern( message_id, js_sys::Uint8Array::from(message_bytes.as_slice()), js_sys::Uint8Array::from(binary.as_slice()), - ); - Ok(()) + ) { + Ok(_) => Ok(()), + Err(e) => { + crate::debug_print!("An error occured during the launch: {e:?}"); + Err(RinfError::NoSignalHandler) + } + } }