tauri-apps / tauri-apps/tauri-docs
[docs] rust frontend crash when a command returns an error with current examples
Nobody has claimed this yet.
- Dominant language
- MDX
- Stars
- 1.1k
- Forks
- 887
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 48
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the current Rust frontend examples and their wasm_bindgen invoke definition, then reproduce a command that returns an Err result. Update the documented example so this case is handled without an unexpected-exception panic, and verify the example behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, wasm
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100