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:
49 files changed
+1004
-363
No files matched your search
@@ -248,6 +248,7 @@ class HyprlandCaptureBackend(CaptureBackend):
|
||||
try:
|
||||
proc.wait_finish(task)
|
||||
except Exception as error:
|
||||
logger.warning(f"[capture] proc.wait_finish(task) failed: {error}")
|
||||
on_result(CaptureResult.failure(str(error)))
|
||||
return
|
||||
if expected.exists():
|
||||
@@ -338,7 +339,10 @@ class HyprlandCaptureBackend(CaptureBackend):
|
||||
def on_done(proc: Gio.Subprocess, task: Gio.Task) -> None:
|
||||
try:
|
||||
_, stdout, _ = proc.communicate_utf8_finish(task)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
f"[capture] _, stdout, _ = proc.communicate_utf8_finish(task) failed: {e}"
|
||||
)
|
||||
on_geometry(None)
|
||||
return
|
||||
on_geometry(stdout.strip() if stdout else None)
|
||||
@@ -372,7 +376,10 @@ class HyprlandCaptureBackend(CaptureBackend):
|
||||
def on_done(proc: Gio.Subprocess, task: Gio.Task) -> None:
|
||||
try:
|
||||
_, stdout, _ = proc.communicate_utf8_finish(task)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
f"[capture] _, stdout, _ = proc.communicate_utf8_finish(task) failed: {e}"
|
||||
)
|
||||
on_geometry(None)
|
||||
return
|
||||
on_geometry(stdout.strip() if stdout else None)
|
||||
|
||||
@@ -11,7 +11,10 @@ def read_dmi(field):
|
||||
try:
|
||||
with open(f"/sys/class/dmi/id/{field}") as f:
|
||||
return f.read().strip()
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
f"[about] with open(f'/sys/class/dmi/id/(field)') as f: return f.re... failed: {e}"
|
||||
)
|
||||
return "Unknown"
|
||||
|
||||
|
||||
@@ -40,7 +43,10 @@ def get_gpu_name():
|
||||
return clean(output[0])
|
||||
|
||||
return "Unknown GPU"
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
f"[about] output = ( subprocess.check_output( 'lspci -nn | grep -i ... failed: {e}"
|
||||
)
|
||||
return "Unknown GPU"
|
||||
|
||||
|
||||
@@ -146,7 +152,10 @@ def get_app_info(wmclass):
|
||||
):
|
||||
desktop_file = full_path
|
||||
break
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
f"[about] full_path = os.path.join(path, f) failed: {e}"
|
||||
)
|
||||
continue
|
||||
|
||||
if desktop_file:
|
||||
@@ -199,7 +208,10 @@ def get_app_info(wmclass):
|
||||
"categories": categories,
|
||||
"desktop_file": desktop_file,
|
||||
}
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
f"[about] with open(desktop_file, encoding='utf-8') as f: content =... failed: {e}"
|
||||
)
|
||||
continue
|
||||
|
||||
# Fallback: try to find executable in PATH
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from fabric.utils import Gdk, GLib
|
||||
from fabric.utils import Gdk, GLib, logger
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
from fabric.widgets.entry import Entry
|
||||
@@ -273,7 +273,10 @@ class WiFiPasswordDialog(Window):
|
||||
self.password_entry.grab_focus()
|
||||
self.password_entry.select_region(0, -1)
|
||||
return False
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
f"[wifi_password_dialog] self.password_entry.grab_focus() failed: {e}"
|
||||
)
|
||||
return False
|
||||
|
||||
def destroy_dialog(self):
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from fabric.utils import GLib
|
||||
from fabric.utils import GLib, logger
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
from fabric.widgets.centerbox import CenterBox
|
||||
@@ -245,8 +245,11 @@ class BatteryControl(Box):
|
||||
self.battery_service.connect(
|
||||
"power_profile_changed", self.on_profile_changed
|
||||
)
|
||||
except TypeError:
|
||||
pass # signal does not exist
|
||||
except TypeError as e:
|
||||
logger.warning(
|
||||
f"[battery_widget] self.battery_service.connect( 'power_profile_changed', se... failed: {e}"
|
||||
)
|
||||
# signal does not exist
|
||||
|
||||
# Initialize display
|
||||
self.update_battery_info()
|
||||
@@ -393,10 +396,14 @@ class BatteryControl(Box):
|
||||
def destroy(self):
|
||||
try:
|
||||
self.battery_service.disconnect_by_func(self.on_battery_changed)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
f"[battery_widget] self.battery_service.disconnect_by_func(self.on_battery_c... failed: {e}"
|
||||
)
|
||||
try:
|
||||
self.battery_service.disconnect_by_func(self.on_profile_changed)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
f"[battery_widget] self.battery_service.disconnect_by_func(self.on_profile_c... failed: {e}"
|
||||
)
|
||||
super().destroy()
|
||||
@@ -99,12 +99,16 @@ class PopupWindow(WaylandWindow):
|
||||
if self._pointing_widget:
|
||||
try:
|
||||
self._pointing_widget.disconnect_by_func(self.do_handle_size_allocate)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
f"[popup_win] self._pointing_widget.disconnect_by_func(self.do_handle_s... failed: {e}"
|
||||
)
|
||||
try:
|
||||
self.disconnect_by_func(self.do_handle_size_allocate)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
f"[popup_win] self.disconnect_by_func(self.do_handle_size_allocate) failed: {e}"
|
||||
)
|
||||
super().destroy()
|
||||
|
||||
def do_calculate_edges(self):
|
||||
|
||||
Reference in new issue
Block a user