Handle invalid JSON settings file

This commit is contained in:
DevilXD committed 2021-12-03 18:11:27 +01:00
1 parent fac2788e4b
commit 071b0f4cd6
1 file changed
+5 -1
+5 -1
View File
@@ -69,7 +69,11 @@ if not os.path.isfile(SETTINGS_PATH):
)
terminate()
with open(SETTINGS_PATH, 'r', encoding="utf8") as file:
settings: Dict[str, Any] = json.load(file)
try:
settings: Dict[str, Any] = json.load(file)
except json.JSONDecodeError as exc:
print(f"Error while reading the settings file:\n{str(exc)}")
terminate()
required_fields = ["channels"]
for field_name in required_fields:
if field_name not in settings: