[docs] rust frontend crash when a command returns an error with current examples
With the current examples, when invoking a command that return an error (a Err variant of a Result type) from a rust frontend, the rust frontend panic with an error about "unexpected exception".
The solution I found is to adjust the wasm_bindgen definition to the following:
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(catch, js_namespace = ["window", "__TAURI__", "core"])]
async fn invoke(cmd: &str, args: JsValue) -> Result<JsValue, JsValue>;
}
And adjust the code using invoke to handle the result.
Maybe a better idea is to define two invoke external functions, one with the catch and one without, I don't know.
Maybe a better idea is to define two invoke external functions, one with the catch and one without, I don't know.
If you have commands that don't return results it would indeed make sense https://github.com/JonasKruckenberg/tauri-sys/blob/v2/src/core.rs#L174-L177
ngl i didn't even know we had some wasm instructions on our website https://v2.tauri.app/develop/calling-rust/#wasm