refactor: log swallowed exceptions across src/

Replace silent swallow-excepts (pass/return/continue) with
logger.warning recording the caught error, preserving behaviour.
This commit is contained in:
sankalp committed 2026-07-14 13:02:21 +05:45
1 parent c0a4b1b792
commit f72542a231
49 files changed
+1004 -363

No files matched your search

+14 -8
View File
@@ -253,8 +253,10 @@ class GlobalMenuDropdowns:
self.global_title_menu_quit.get_child().get_start_children()[0].set_label(
f"Quit {value}"
)
except Exception:
pass
except Exception as e:
logger.warning(
f"[globalmenu] self.global_title_menu_about.get_child().get_start_childr... failed: {e}"
)
# Notify the global menu service about the active window change
if self._global_menu_svc:
@@ -284,15 +286,17 @@ class GlobalMenuDropdowns:
if btn.get_parent():
btn.get_parent().remove(btn)
btn.destroy()
except Exception:
pass
except Exception as e:
logger.warning(
f"[globalmenu] if btn.get_parent(): btn.get_parent().remove(btn) failed: {e}"
)
# Clean up any previous dynamic dropdowns
for dd in self._dynamic_dropdowns:
try:
dd.destroy()
except Exception:
pass
except Exception as e:
logger.warning(f"[globalmenu] dd.destroy() failed: {e}")
self._dynamic_dropdowns.clear()
# Filter to visible top-level menu items only
@@ -413,8 +417,10 @@ class GlobalMenuDropdowns:
if self._global_menu_svc:
try:
self._global_menu_svc.disconnect_by_func(self._on_menu_changed)
except Exception:
pass
except Exception as e:
logger.warning(
f"[globalmenu] self._global_menu_svc.disconnect_by_func(self._on_menu_ch... failed: {e}"
)
# Destroy dynamic dropdowns
for dd in self._dynamic_dropdowns:
+12 -6
View File
@@ -343,12 +343,16 @@ class MicrophoneIndicator(Box):
if old is not None and old is not mic:
try:
old.disconnect_by_func(self._on_mic_stream_changed)
except Exception:
pass
except Exception as e:
logger.warning(
f"[indicators] old.disconnect_by_func(self._on_mic_stream_changed) failed: {e}"
)
try:
mic.disconnect_by_func(self._on_mic_stream_changed)
except Exception:
pass
except Exception as e:
logger.warning(
f"[indicators] mic.disconnect_by_func(self._on_mic_stream_changed) failed: {e}"
)
mic.connect("changed", self._on_mic_stream_changed)
self._mic_device = mic
self._sync_state()
@@ -386,8 +390,10 @@ class MicrophoneIndicator(Box):
self._hide_timer_id = 0
try:
self._audio.disconnect_by_func(self._on_mic_device_changed)
except Exception:
pass
except Exception as e:
logger.warning(
f"[indicators] self._audio.disconnect_by_func(self._on_mic_device_changed) failed: {e}"
)
old = getattr(self, "_mic_device", None)
target = old if old is not None else self._audio.microphone
if target is not None:
+5 -3
View File
@@ -1,4 +1,4 @@
from fabric.utils import Gdk, GLib, Gtk
from fabric.utils import Gdk, GLib, Gtk, logger
from fabric.widgets.box import Box
from fabric.widgets.centerbox import CenterBox
from fabric.widgets.shapes import Corner
@@ -192,8 +192,10 @@ class Notch(Box):
svc = self._mpris.get_player_service(name)
if svc is not None:
svc.disconnect_by_func(self._on_any_artwork)
except Exception:
pass
except Exception as e:
logger.warning(
f"[notch] svc = self._mpris.get_player_service(name) failed: {e}"
)
self._apply_stack_state()
# ── Scroll ────────────────────────────────────────────────────────────────
+9 -4
View File
@@ -2,7 +2,7 @@ import math
import os
import time
from fabric.utils import GdkPixbuf, GLib, Gtk
from fabric.utils import GdkPixbuf, GLib, Gtk, logger
from fabric.widgets.box import Box
from fabric.widgets.centerbox import CenterBox
@@ -146,8 +146,10 @@ class NotchPlayer(Box):
for sid in self._sigs:
try:
self._service.disconnect(sid)
except Exception:
pass
except Exception as e:
logger.warning(
f"[player] self._service.disconnect(sid) failed: {e}"
)
self._sigs.clear()
def _on_play(self, *_) -> None:
@@ -185,7 +187,10 @@ class NotchPlayer(Box):
self.artwork_image.set_from_pixbuf(pixbuf)
self.fallback_icon.set_visible(False)
self.artwork_image.set_visible(True)
except Exception:
except Exception as e:
logger.warning(
f"[player] pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale( path, 1... failed: {e}"
)
self._show_fallback()
def _update_from_service(self) -> None:
+5 -3
View File
@@ -1,4 +1,4 @@
from fabric.utils import GLib, time
from fabric.utils import GLib, logger, time
from fabric.widgets.box import Box
from fabric.widgets.button import Button
from fabric.widgets.centerbox import CenterBox
@@ -73,8 +73,10 @@ class RecordingIndicator(Box):
try:
screen_capture_service.stop_recording()
self.stop_timer()
except Exception:
pass
except Exception as e:
logger.warning(
f"[recording] screen_capture_service.stop_recording() failed: {e}"
)
def destroy(self):
self.stop_timer()