From 38d4da9f863e83388bcb23be48d7bc6a1186267f Mon Sep 17 00:00:00 2001 From: J M <2364004+Blu-J@users.noreply.github.com> Date: Wed, 19 Jan 2022 16:13:26 -0700 Subject: [PATCH] Fix/show errors (#1075) * chore: Show errors * chore: Quick fix --- appmgr/src/net/wifi.rs | 59 +++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/appmgr/src/net/wifi.rs b/appmgr/src/net/wifi.rs index ac3dd7247..e539973c7 100644 --- a/appmgr/src/net/wifi.rs +++ b/appmgr/src/net/wifi.rs @@ -69,22 +69,21 @@ pub async fn add( drop(wpa_supplicant); Ok(()) } - tokio::spawn(async move { - match add_procedure( - &mut ctx.db.handle(), - ctx.wifi_manager.clone(), - &Ssid(ssid.clone()), - &Psk(password.clone()), - priority, - ) - .await - { - Err(e) => { - tracing::info!("Failed to add new WiFi network '{}': {}", ssid, e); - } - Ok(_) => {} - } - }); + if let Err(err) = add_procedure( + &mut ctx.db.handle(), + ctx.wifi_manager.clone(), + &Ssid(ssid.clone()), + &Psk(password.clone()), + priority, + ) + .await + { + tracing::error!("Failed to add new WiFi network '{}': {}", ssid, err); + return Err(Error::new( + color_eyre::eyre::eyre!("Failed adding {}", ssid), + ErrorKind::Wifi, + )); + } Ok(()) } @@ -122,20 +121,20 @@ pub async fn connect(#[context] ctx: RpcContext, #[arg] ssid: String) -> Result< } Ok(()) } - tokio::spawn(async move { - match connect_procedure( - &mut ctx.db.handle(), - ctx.wifi_manager.clone(), - &Ssid(ssid.clone()), - ) - .await - { - Err(e) => { - tracing::info!("Failed to connect to WiFi network '{}': {}", &ssid, e); - } - Ok(_) => {} - } - }); + + if let Err(err) = connect_procedure( + &mut ctx.db.handle(), + ctx.wifi_manager.clone(), + &Ssid(ssid.clone()), + ) + .await + { + tracing::error!("Failed to connect to WiFi network '{}': {}", &ssid, err); + return Err(Error::new( + color_eyre::eyre::eyre!("Can't connect to {}", ssid), + ErrorKind::Wifi, + )); + } Ok(()) }