Maybe to explain in more detail: I have a command that I want to be fallible, and needs to be checked on the Frontend to have succeeded (i.e. with try {await invoke(...)} catch (e) { console.log("oh no") }), so the signature is something like
use tauri::api::dialog::blocking::FileDialogBuilder as Dialog;
#[tauri::command]
pub fn open_folder_and_do_something() -> Result<(), String> {
let path = Dialog::new().pick_folder().ok_or("no folder picked")?;
some_other_result_fn(&path)?; // if this isn't Ok, the frontend has to know
Ok(())
}
I want to be able to call the same command from a menu handler. I don't know what's the recommended / standard approach for something like this. I assume it's a frequently encountered need.
Since the command is fallible, I cannot easily use the non-blocking picker, as there's no way to find out if some_other_result_fn is Ok, as it would only be called and returned from in the pick_folder(|path| {some_other_result_fn(path)}) closure.