Skip to content

Commit 2319dd9

Browse files
committed
make some errors show as infos in the notif
1 parent 38a49b9 commit 2319dd9

4 files changed

Lines changed: 31 additions & 13 deletions

File tree

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async fn main() -> Result<()> {
3232

3333
let backend = CrosstermBackend::new(io::stdout());
3434
let terminal = Terminal::new(backend)?;
35-
let events = EventHandler::new(2_000);
35+
let events = EventHandler::new(1_000);
3636
let mut tui = Tui::new(terminal, events);
3737
tui.init()?;
3838

src/mode/station.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::sync::Arc;
77

88
use futures::future::join_all;
99
use iwdrs::{
10+
error::{IWDError, station::ScanError},
1011
session::Session,
1112
station::{State, diagnostics::ActiveStationDiagnostics},
1213
};
@@ -236,7 +237,19 @@ impl Station {
236237
NotificationLevel::Info,
237238
&sender,
238239
)?,
239-
Err(e) => Notification::send(e.to_string(), NotificationLevel::Error, &sender.clone())?,
240+
Err(e) => match e {
241+
IWDError::OperationError(e) => match e {
242+
ScanError::Busy => {
243+
Notification::send(e.to_string(), NotificationLevel::Info, &sender.clone())?
244+
}
245+
_ => Notification::send(
246+
e.to_string(),
247+
NotificationLevel::Error,
248+
&sender.clone(),
249+
)?,
250+
},
251+
_ => Notification::send(e.to_string(), NotificationLevel::Error, &sender.clone())?,
252+
},
240253
}
241254

242255
Ok(())

src/mode/station/network.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use anyhow::Result;
2-
use iwdrs::network::{Network as iwdNetwork, NetworkType};
2+
use iwdrs::{
3+
error::{IWDError, network::ConnectError},
4+
network::{Network as iwdNetwork, NetworkType},
5+
};
36
use tokio::sync::mpsc::UnboundedSender;
47

58
use crate::{
@@ -48,17 +51,19 @@ impl Network {
4851
NotificationLevel::Info,
4952
&sender,
5053
)?,
51-
Err(e) => {
52-
if e.to_string().contains("net.connman.iwd.Aborted") {
53-
Notification::send(
54-
"Connection canceled".to_string(),
55-
NotificationLevel::Info,
56-
&sender,
57-
)?;
58-
} else {
54+
Err(e) => match e {
55+
IWDError::OperationError(e) => match e {
56+
ConnectError::Aborted => {
57+
Notification::send(e.to_string(), NotificationLevel::Info, &sender)?;
58+
}
59+
_ => {
60+
Notification::send(e.to_string(), NotificationLevel::Error, &sender)?;
61+
}
62+
},
63+
_ => {
5964
Notification::send(e.to_string(), NotificationLevel::Error, &sender)?;
6065
}
61-
}
66+
},
6267
}
6368
Ok(())
6469
}

src/notification.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl Notification {
7070
let notif = Notification {
7171
message,
7272
level,
73-
ttl: 2,
73+
ttl: 3,
7474
};
7575

7676
sender.send(Event::Notification(notif))?;

0 commit comments

Comments
 (0)