Explorar o código

Show a clean error message when config.json has invalid JSON

ZiB hai 4 meses
pai
achega
5febe60926
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      room_cal/_utils.py

+ 4 - 1
room_cal/_utils.py

@@ -435,7 +435,10 @@ def get_config() -> Config:
   override_path = data_home() / 'config.json'
   if not override_path.exists():
     return Config.from_dict(default)
-  override = json.loads(override_path.read_text(encoding='utf-8'))
+  try:
+    override = json.loads(override_path.read_text(encoding='utf-8'))
+  except json.JSONDecodeError as e:
+    raise SystemExit(f"config.json parse error: {e}") from None
   return Config.from_dict(_deep_merge(default, override))