improve error handling
This commit is contained in:
parent
c9fa93de72
commit
355febf927
12 changed files with 443 additions and 258 deletions
|
@ -5,7 +5,7 @@
|
|||
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
use tauri::{State, Manager};
|
||||
use tauri::{Manager, State};
|
||||
|
||||
struct Received(AtomicBool);
|
||||
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
|
||||
|
@ -28,7 +28,10 @@ fn main() {
|
|||
|
||||
let app_handle = app.handle();
|
||||
app.listen_global("foo", move |_| {
|
||||
app_handle.state::<Received>().0.store(true, Ordering::Relaxed);
|
||||
app_handle
|
||||
.state::<Received>()
|
||||
.0
|
||||
.store(true, Ordering::Relaxed);
|
||||
});
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -31,4 +31,4 @@ pub async fn get_tauri_version() -> anyhow::Result<()> {
|
|||
ensure!(version.pre.is_empty());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,4 +9,4 @@ pub async fn test() -> anyhow::Result<()> {
|
|||
ensure!(text == Some("foobar".to_string()));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,9 @@ use tauri_sys::{event, tauri};
|
|||
pub async fn emit() -> anyhow::Result<()> {
|
||||
event::emit("foo", &"bar").await;
|
||||
|
||||
ensure!(tauri::invoke::<_, bool>("verify_receive", &()).await.unwrap());
|
||||
ensure!(tauri::invoke::<_, bool>("verify_receive", &())
|
||||
.await
|
||||
.unwrap());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,9 @@ async fn exit_with_error(e: String) {
|
|||
e: String,
|
||||
}
|
||||
|
||||
tauri_sys::tauri::invoke::<_, ()>("exit_with_error", &Args { e }).await.unwrap();
|
||||
tauri_sys::tauri::invoke::<_, ()>("exit_with_error", &Args { e })
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[derive(Props)]
|
||||
|
|
|
@ -10,4 +10,4 @@ pub async fn create_window() -> anyhow::Result<()> {
|
|||
win.close().await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue