From 36ecff71aea2c9c9f296ae1e0b5da00a3aea26d3 Mon Sep 17 00:00:00 2001 From: w-e-w <40751091+w-e-w@users.noreply.github.com> Date: Sun, 20 Aug 2023 15:36:39 +0900 Subject: catch error when loading config_states and save config_states with indent --- modules/config_states.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'modules/config_states.py') diff --git a/modules/config_states.py b/modules/config_states.py index 6f1ab53f..62d40106 100644 --- a/modules/config_states.py +++ b/modules/config_states.py @@ -28,10 +28,13 @@ def list_config_states(): for filename in os.listdir(config_states_dir): if filename.endswith(".json"): path = os.path.join(config_states_dir, filename) - with open(path, "r", encoding="utf-8") as f: - j = json.load(f) - j["filepath"] = path - config_states.append(j) + try: + with open(path, "r", encoding="utf-8") as f: + j = json.load(f) + j["filepath"] = path + config_states.append(j) + except Exception as e: + print(f'[ERROR]{path}, {e}') config_states = sorted(config_states, key=lambda cs: cs["created_at"], reverse=True) -- cgit v1.2.3