Handle invalid JSON settings file
This commit is contained in:
1 parent
fac2788e4b
commit
071b0f4cd6
1 file changed
+5
-1
@@ -69,7 +69,11 @@ if not os.path.isfile(SETTINGS_PATH):
|
|||||||
)
|
)
|
||||||
terminate()
|
terminate()
|
||||||
with open(SETTINGS_PATH, 'r', encoding="utf8") as file:
|
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"]
|
required_fields = ["channels"]
|
||||||
for field_name in required_fields:
|
for field_name in required_fields:
|
||||||
if field_name not in settings:
|
if field_name not in settings:
|
||||||
|
|||||||
Reference in new issue
Block a user