mirror of
https://github.com/aclist/dztui.git
synced 2026-10-30 22:52:42 +01:00
chore: format exceptions with type
This commit is contained in:
1 parent
83a7996189
commit
2419fedd19
5 files changed
+14
-6
No files matched your search
@@ -14,6 +14,7 @@ from typing import Any, Optional, TYPE_CHECKING, Union
|
|||||||
from dzgui.api.bm import map_id_to_record
|
from dzgui.api.bm import map_id_to_record
|
||||||
from dzgui.const.constants import APP_NAME, REQUEST_TIMEOUT
|
from dzgui.const.constants import APP_NAME, REQUEST_TIMEOUT
|
||||||
from dzgui.const.endpoints import STEAM_SERVERS
|
from dzgui.const.endpoints import STEAM_SERVERS
|
||||||
|
from dzgui.util.format import format_exception
|
||||||
from dzgui.util import strings
|
from dzgui.util import strings
|
||||||
|
|
||||||
import a2s
|
import a2s
|
||||||
@@ -273,7 +274,9 @@ def source_info_to_dict(ip: str, qport: int, info: "SourceInfo") -> dict[str, An
|
|||||||
return res
|
return res
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# TODO: generalized function
|
# TODO: generalized function
|
||||||
logger.critical(f"{type(e).__name__}: {e} ({ip}:{qport})")
|
msg = format_exception(e)
|
||||||
|
msg += f" ({ip}:{qport})"
|
||||||
|
logger.critical(msg)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -238,8 +238,7 @@ class ConnectionManager:
|
|||||||
def query_modlist_and_present(self, record: Servers.Record) -> None:
|
def query_modlist_and_present(self, record: Servers.Record) -> None:
|
||||||
try:
|
try:
|
||||||
mods = self._query_modlist(record)
|
mods = self._query_modlist(record)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
print(f"{type(e).__name__}: {e}")
|
|
||||||
self.thread_man.set_cleanup_func(
|
self.thread_man.set_cleanup_func(
|
||||||
StoredFunc(self._server_timeout), destroy_first=True
|
StoredFunc(self._server_timeout), destroy_first=True
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -83,3 +83,7 @@ def format_player_count(model: Gtk.TreeModel | None, control: list) -> str:
|
|||||||
|
|
||||||
def embolden(text: str) -> str:
|
def embolden(text: str) -> str:
|
||||||
return f"<b>{text}</b>"
|
return f"<b>{text}</b>"
|
||||||
|
|
||||||
|
|
||||||
|
def format_exception(e: Exception) -> str:
|
||||||
|
return f"{type(e).__name__}: {e}"
|
||||||
@@ -11,6 +11,7 @@ from dzgui.const.constants import (
|
|||||||
)
|
)
|
||||||
from dzgui.const.enum import FilterMode
|
from dzgui.const.enum import FilterMode
|
||||||
from dzgui.model.servers import ServerModelManager
|
from dzgui.model.servers import ServerModelManager
|
||||||
|
from dzgui.util.format import format_exception
|
||||||
from dzgui.util.strings import all_maps
|
from dzgui.util.strings import all_maps
|
||||||
from dzgui.views.components.maps_combo import MapsCombo
|
from dzgui.views.components.maps_combo import MapsCombo
|
||||||
from dzgui.views.components.labels import BoldLabel
|
from dzgui.views.components.labels import BoldLabel
|
||||||
@@ -338,4 +339,5 @@ class FilterPanel(Gtk.Box):
|
|||||||
label = check.get_label()
|
label = check.get_label()
|
||||||
check.set_active(filters[label])
|
check.set_active(filters[label])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(e)
|
msg = format_exception(e)
|
||||||
|
logger.warning(msg)
|
||||||
@@ -14,6 +14,7 @@ from dzgui.init.update import check_updates
|
|||||||
from dzgui.const.constants import EXPAND, FILL
|
from dzgui.const.constants import EXPAND, FILL
|
||||||
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
||||||
from dzgui.strings import preboot
|
from dzgui.strings import preboot
|
||||||
|
from dzgui.util.format import format_exception
|
||||||
from dzgui.util.strings import dialog_header
|
from dzgui.util.strings import dialog_header
|
||||||
from dzgui.util.symlink import rebuild_symlinks
|
from dzgui.util.symlink import rebuild_symlinks
|
||||||
from dzgui.views.components.buttons import ClipboardButton
|
from dzgui.views.components.buttons import ClipboardButton
|
||||||
@@ -175,8 +176,7 @@ class BootDialog(Gtk.Dialog):
|
|||||||
self.thread_man.set_cleanup_func(callback)
|
self.thread_man.set_cleanup_func(callback)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.failed = True
|
self.failed = True
|
||||||
# TODO: generic exception wrapper
|
self.exception = format_exception(e)
|
||||||
self.exception = f"{type(e).__name__}: {e}"
|
|
||||||
callback = StoredFunc(self.update_status, Success.FAIL)
|
callback = StoredFunc(self.update_status, Success.FAIL)
|
||||||
self.thread_man.set_cleanup_func(callback)
|
self.thread_man.set_cleanup_func(callback)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user