From 881482efd63f36cc0ebe6de3b38ea169ca8ea216 Mon Sep 17 00:00:00 2001 From: Michael Loukeris Date: Thu, 17 Oct 2024 21:48:29 +0300 Subject: [PATCH] Guard against malformed json file --- src/app.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app.py b/src/app.py index ce5e2eb..e800050 100644 --- a/src/app.py +++ b/src/app.py @@ -59,7 +59,15 @@ def load_config(self, config_file): with open(config_file, "r") as file: file_contents = file.read() - self.config = json.loads(file_contents) + try: + self.config = json.loads(file_contents) + except json.JSONDecodeError as e: + logger.log_error(f"Error loading config file: {e}") + self.gui.draw_log("Your config.json file is not a valid json file...") + self.gui.draw_paint() + time.sleep(self.LOG_WAIT) + sys.exit() + self.roms_path = self.config.get("roms") self.systems_logo_path = self.config.get("logos") self.colors = self.config.get("colors")