fix: add error handling to load_config

This commit is contained in:
OpenCode Bot
2026-05-24 22:42:55 +08:00
parent 38a273eb3d
commit 1b1dc933fc

View File

@@ -7,8 +7,11 @@ CONFIG_PATH = os.path.join(os.path.dirname(__file__), 'config.json')
def load_config(): def load_config():
if os.path.exists(CONFIG_PATH): if os.path.exists(CONFIG_PATH):
try:
with open(CONFIG_PATH, 'r') as f: with open(CONFIG_PATH, 'r') as f:
return json.load(f) return json.load(f)
except (json.JSONDecodeError, IOError):
return {"server_url": "http://localhost:5000", "default_expiry": "24h"}
return {"server_url": "http://localhost:5000", "default_expiry": "24h"} return {"server_url": "http://localhost:5000", "default_expiry": "24h"}
def save_config(config): def save_config(config):