From ddecb1ce5776104e085f786ebe455f77f220e6ed Mon Sep 17 00:00:00 2001 From: 18870 Date: Thu, 28 Oct 2021 23:18:01 +0800 Subject: [PATCH] Opt: Catch and show exception when load config --- alas.py | 12 ++++++++---- module/webui/utils.py | 6 +++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/alas.py b/alas.py index b82b72e36..bdac5843b 100644 --- a/alas.py +++ b/alas.py @@ -21,10 +21,14 @@ class AzurLaneAutoScript: @cached_property def config(self): - config = AzurLaneConfig(config_name=self.config_name) - # Set server before loading any buttons. - server.server = deep_get(config.data, keys='Alas.Emulator.Server', default='cn') - return config + try: + config = AzurLaneConfig(config_name=self.config_name) + # Set server before loading any buttons. + server.server = deep_get(config.data, keys='Alas.Emulator.Server', default='cn') + return config + except Exception as e: + logger.exception(e) + exit(1) @cached_property def device(self): diff --git a/module/webui/utils.py b/module/webui/utils.py index 6f2a88426..01d838f85 100644 --- a/module/webui/utils.py +++ b/module/webui/utils.py @@ -132,7 +132,11 @@ class TaskHandler: task = self.tasks[0] if task.next_run < time.time(): start_time = time.time() - next(task) + try: + next(task) + except Exception as e: + logger.exception(e) + self.remove_task(task, nowait=True) end_time = time.time() task.next_run += task.delay with self._lock: