refactor(src/window):improve error handling with logging
This commit is contained in:
26 files changed
+239
-211
No files matched your search
@@ -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()
|
||||
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
Reference in new issue
Block a user