notifications: better error logs
This commit is contained in:
@@ -41,9 +41,15 @@ impl NotificationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_dbus(&mut self) {
|
pub fn run_dbus(&mut self) {
|
||||||
let Ok(c) = Connection::new_session() else {
|
let c = match Connection::new_session() {
|
||||||
log::error!("Failed to connect to dbus. Desktop notifications will not work.");
|
Ok(c) => c,
|
||||||
|
Err(e) => {
|
||||||
|
log::error!(
|
||||||
|
"Failed to connect to dbus. Desktop notifications will not work. Cause: {:?}",
|
||||||
|
e
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut rule = MatchRule::new_method_call();
|
let mut rule = MatchRule::new_method_call();
|
||||||
@@ -54,7 +60,7 @@ impl NotificationManager {
|
|||||||
|
|
||||||
let sender = self.tx_toast.clone();
|
let sender = self.tx_toast.clone();
|
||||||
|
|
||||||
let Ok(token) = c.add_match(rule, move |_: (), _, msg| {
|
let token = match c.add_match(rule, move |_: (), _, msg| {
|
||||||
if let Ok(toast) = parse_dbus(&msg) {
|
if let Ok(toast) = parse_dbus(&msg) {
|
||||||
match sender.try_send(toast) {
|
match sender.try_send(toast) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
@@ -64,9 +70,15 @@ impl NotificationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}) else {
|
}) {
|
||||||
log::error!("Failed to add dbus match. Desktop notifications will not work.");
|
Ok(t) => t,
|
||||||
|
Err(e) => {
|
||||||
|
log::error!(
|
||||||
|
"Failed to eavesdrop. Desktop notifications will not work. Cause: {:?}",
|
||||||
|
e
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.dbus_data = Some((c, token));
|
self.dbus_data = Some((c, token));
|
||||||
@@ -76,10 +88,11 @@ impl NotificationManager {
|
|||||||
let sender = self.tx_toast.clone();
|
let sender = self.tx_toast.clone();
|
||||||
// NOTE: We're detaching the thread, as there's no simple way to gracefully stop it other than app shutdown.
|
// NOTE: We're detaching the thread, as there's no simple way to gracefully stop it other than app shutdown.
|
||||||
let _ = std::thread::spawn(move || {
|
let _ = std::thread::spawn(move || {
|
||||||
let socket = match std::net::UdpSocket::bind("127.0.0.1:42069") {
|
let addr = "127.0.0.1:42069";
|
||||||
|
let socket = match std::net::UdpSocket::bind(addr) {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Failed to bind notification socket: {:?}", e);
|
log::error!("Failed to bind notification socket @ {}: {:?}", addr, e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user