refactor(src/window):improve error handling with logging

This commit is contained in:
sankalp committed 2026-06-17 05:21:36 +05:45
1 parent 420688e9a7
commit 9cbde2c58f
26 files changed
+239 -211

No files matched your search

+7 -7
View File
@@ -1,5 +1,5 @@
from fabric.hyprland.widgets import HyprlandActiveWindow as ActiveWindow
from fabric.utils import FormattedString, exec_shell_command_async
from fabric.utils import FormattedString, exec_shell_command_async, logger
from fabric.widgets.box import Box
from fabric.widgets.button import Button
from fabric.widgets.centerbox import CenterBox
@@ -312,8 +312,8 @@ class GlobalMenuDropdowns:
modus_service.disconnect_by_func(self._on_active_app_changed)
modus_service.disconnect_by_func(self.changed_dropdown)
modus_service.disconnect_by_func(self.hide_dropdowns)
except Exception:
pass
except Exception as e:
logger.error(f"An error occurred: {e}")
# Destroy all dropdown captures
dropdown_captures = [
@@ -327,8 +327,8 @@ class GlobalMenuDropdowns:
try:
if capture and hasattr(capture, "destroy"):
capture.destroy()
except Exception:
pass
except Exception as e:
logger.error(f"An error occurred: {e}")
super().destroy()
@@ -364,6 +364,6 @@ class GlobalMenu(Box):
if hasattr(self, "dropdown_system") and self.dropdown_system:
try:
self.dropdown_system.destroy()
except Exception:
pass
except Exception as e:
logger.error(f"An error occurred: {e}")
super().destroy()
+14 -13
View File
@@ -1,3 +1,4 @@
from fabric.utils import logger
from fabric.bluetooth import BluetoothClient
from fabric.widgets.box import Box
from fabric.widgets.button import Button
@@ -465,7 +466,7 @@ class BatteryIndicator(Box):
if hasattr(self, "battery_service") and self.battery_service:
self.battery_service.disconnect_by_func(self.on_battery_direct_changed)
except Exception as e:
print(f"Error disconnecting battery indicator signals: {e}")
logger.error(f"Error disconnecting battery indicator signals: {e}")
# Destroy window and widget
try:
@@ -473,8 +474,8 @@ class BatteryIndicator(Box):
self.battery_widget.destroy()
if hasattr(self, "battery_window") and self.battery_window:
self.battery_window.destroy()
except Exception:
pass
except Exception as e:
logger.error(f"An error occurred: {e}")
super().destroy()
@@ -491,14 +492,14 @@ def add_destroy_to_indicators():
self.bluetooth.disconnect_by_func(self.on_device_added)
self.bluetooth.disconnect_by_func(self.on_device_removed)
except Exception as e:
print(f"Error disconnecting bluetooth indicator signals: {e}")
logger.error(f"Error disconnecting bluetooth indicator signals: {e}")
try:
if hasattr(self, "bluetooth_widget") and self.bluetooth_widget:
self.bluetooth_widget.destroy()
if hasattr(self, "bluetooth_window") and self.bluetooth_window:
self.bluetooth_window.destroy()
except Exception:
pass
except Exception as e:
logger.error(f"An error occurred: {e}")
Box.destroy(self)
BluetoothIndicator.destroy = bt_destroy
@@ -521,8 +522,8 @@ def add_destroy_to_indicators():
self.network_service.wifi_device.disconnect_by_func(
self.on_network_direct_changed
)
except Exception:
pass
except Exception as e:
logger.error(f"An error occurred: {e}")
if (
hasattr(self.network_service, "ethernet_device")
and self.network_service.ethernet_device
@@ -531,17 +532,17 @@ def add_destroy_to_indicators():
self.network_service.ethernet_device.disconnect_by_func(
self.on_network_direct_changed
)
except Exception:
pass
except Exception as e:
logger.error(f"An error occurred: {e}")
except Exception as e:
print(f"Error disconnecting network indicator signals: {e}")
logger.error(f"Error disconnecting network indicator signals: {e}")
try:
if hasattr(self, "wifi_widget") and self.wifi_widget:
self.wifi_widget.destroy()
if hasattr(self, "wifi_window") and self.wifi_window:
self.wifi_window.destroy()
except Exception:
pass
except Exception as e:
logger.error(f"An error occurred: {e}")
Box.destroy(self)
NetworkIndicator.destroy = net_destroy
@@ -1,4 +1,4 @@
from fabric.utils import GLib, os, time
from fabric.utils import GLib, os, time, logger
from fabric.widgets.box import Box
from fabric.widgets.button import Button
from fabric.widgets.label import Label
@@ -41,14 +41,14 @@ class RecordingIndicator(Button):
# Prevent container.show_all() from forcing this visible when no recording
try:
self.set_no_show_all(True)
except Exception:
pass
except Exception as e:
logger.error(f"An error occurred: {e}")
self.connect("clicked", self.on_stop_recording)
try:
setup_cursor_hover(self, "pointer")
except Exception:
pass
except Exception as e:
logger.error(f"An error occurred: {e}")
self.connect("button-press-event", self.on_button_press)
self.set_visible(False)
@@ -86,7 +86,7 @@ class RecordingIndicator(Button):
self.cleanup_recording_state()
except Exception as e:
print(f"[DEBUG] Error checking recording status: {e}")
logger.error(f"[DEBUG] Error checking recording status: {e}")
if self.get_visible():
self.set_visible(False)
self.cleanup_recording_state()
@@ -110,7 +110,7 @@ class RecordingIndicator(Button):
return True
except Exception as e:
print(f"[DEBUG] Error updating timer display: {e}")
logger.error(f"[DEBUG] Error updating timer display: {e}")
return False
def cleanup_recording_state(self):
@@ -197,7 +197,7 @@ class RecordingIndicator(Button):
)
except Exception as e:
print(f"[DEBUG] Error in delayed recording indicator init: {e}")
logger.error(f"[DEBUG] Error in delayed recording indicator init: {e}")
return False
def destroy(self):
+3 -2
View File
@@ -1,3 +1,4 @@
from fabric.utils import logger
from fabric.hyprland.widgets import HyprlandWorkspaces, WorkspaceButton
from fabric.widgets.box import Box
@@ -105,8 +106,8 @@ class WorkspaceIndicator(Box):
if self._on_config_changed in _config_handlers:
_config_handlers.remove(self._on_config_changed)
except Exception:
pass
except Exception as e:
logger.error(f"An error occurred: {e}")
if hasattr(self, "workspaces") and self.workspaces:
self.workspaces.destroy()
Box.destroy(self)
+7 -6
View File
@@ -1,3 +1,4 @@
from fabric.utils import logger
from fabric.system_tray.widgets import SystemTray
from fabric.widgets.box import Box
from fabric.widgets.button import Button
@@ -312,8 +313,8 @@ class Panel(Window):
if self._on_config_changed in _config_handlers:
_config_handlers.remove(self._on_config_changed)
except Exception:
pass
except Exception as e:
logger.error(f"An error occurred: {e}")
# Destroy components
for component in [
@@ -324,14 +325,14 @@ class Panel(Window):
]:
try:
component.destroy()
except Exception:
pass
except Exception as e:
logger.error(f"An error occurred: {e}")
# Destroy MouseCapture windows
for mc in [self.control_center, self.notification_center]:
try:
mc.destroy()
except Exception:
pass
except Exception as e:
logger.error(f"An error occurred: {e}")
super().destroy()