Opt: Catch and show exception when load config

This commit is contained in:
18870 2021-10-28 23:18:01 +08:00
parent d2d23345d0
commit ddecb1ce57
2 changed files with 13 additions and 5 deletions

12
alas.py
View File

@ -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):

View File

@ -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: