feat(bar): add more logging around error paths

This commit is contained in:
LGUG2Z
2024-10-09 15:06:48 -07:00
parent c57759242a
commit bc00f54c90
2 changed files with 102 additions and 86 deletions

View File

@@ -5,6 +5,7 @@ use crate::widget::BarWidget;
use crate::MAX_LABEL_WIDTH;
use crate::WIDGET_SPACING;
use crossbeam_channel::Receiver;
use crossbeam_channel::TryRecvError;
use eframe::egui::text::LayoutJob;
use eframe::egui::Color32;
use eframe::egui::ColorImage;
@@ -437,7 +438,16 @@ impl KomorebiNotificationState {
rx_gui: Receiver<komorebi_client::Notification>,
bg_color: Rc<RefCell<Color32>>,
) {
if let Ok(notification) = rx_gui.try_recv() {
match rx_gui.try_recv() {
Err(error) => match error {
TryRecvError::Empty => {}
TryRecvError::Disconnected => {
tracing::error!(
"failed to receive komorebi notification on gui thread: {error}"
);
}
},
Ok(notification) => {
if let NotificationEvent::Socket(SocketMessage::ReloadStaticConfiguration(path)) =
notification.event
{
@@ -471,7 +481,8 @@ impl KomorebiNotificationState {
};
if should_add {
workspaces.push(ws.name().to_owned().unwrap_or_else(|| format!("{}", i + 1)));
workspaces
.push(ws.name().to_owned().unwrap_or_else(|| format!("{}", i + 1)));
}
}
@@ -489,7 +500,8 @@ impl KomorebiNotificationState {
self.layout = KomorebiLayout::Paused;
}
if let Some(container) = monitor.workspaces()[focused_workspace_idx].monocle_container()
if let Some(container) =
monitor.workspaces()[focused_workspace_idx].monocle_container()
{
self.focused_container_information = (
container
@@ -527,4 +539,5 @@ impl KomorebiNotificationState {
}
}
}
}
}

View File

@@ -1,7 +1,7 @@
mod bar;
mod cpu;
mod battery;
mod config;
mod cpu;
mod date;
mod komorebi;
mod media;
@@ -370,19 +370,22 @@ fn main() -> color_eyre::Result<()> {
match String::from_utf8(buffer) {
Ok(notification_string) => {
if let Ok(notification) =
serde_json::from_str::<komorebi_client::Notification>(
match serde_json::from_str::<komorebi_client::Notification>(
&notification_string,
)
{
) {
Ok(notification) => {
tracing::debug!("received notification from komorebi");
if let Err(error) = tx_gui.send(notification) {
tracing::error!("could not send komorebi notification update to gui: {error}")
tracing::error!("could not send komorebi notification update to gui thread: {error}")
}
ctx_komorebi.request_repaint();
}
Err(error) => {
tracing::error!("could not deserialize komorebi notification: {error}");
}
}
}
Err(error) => {
tracing::error!(