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.