return structured errors from commands (wip)

This commit is contained in:
2022-12-23 11:34:17 -08:00
parent 2943634248
commit df6b362a31
8 changed files with 82 additions and 62 deletions

View File

@ -3,7 +3,7 @@
windows_subsystem = "windows"
)]
use tauri::{AppHandle, Manager};
use tauri::{AppHandle, Manager, async_runtime as rt};
use once_cell::sync::OnceCell;
mod config;
@ -14,13 +14,14 @@ mod state;
mod server;
mod tray;
use crate::errors::*;
use state::AppState;
pub static APP: OnceCell<AppHandle> = OnceCell::new();
fn main() {
let initial_state = match state::AppState::new() {
let initial_state = match rt::block_on(state::AppState::load()) {
Ok(state) => state,
Err(e) => {eprintln!("{}", e); return;}
};
@ -42,6 +43,12 @@ fn main() {
let config = state.config.read().unwrap();
let addr = std::net::SocketAddrV4::new(config.listen_addr, config.listen_port);
tauri::async_runtime::spawn(server::serve(addr, app.handle()));
if !config.start_minimized {
app.get_window("main")
.ok_or(RequestError::NoMainWindow)?
.show()?;
}
Ok(())
})
.build(tauri::generate_context!())