From 071b0f4cd63307dc02410a60550f9b57692580b9 Mon Sep 17 00:00:00 2001 From: DevilXD Date: Fri, 3 Dec 2021 18:11:27 +0100 Subject: [PATCH] Handle invalid JSON settings file --- main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 46de812..6415c81 100644 --- a/main.py +++ b/main.py @@ -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: