Skip to content

Commit

Permalink
Guard against malformed json file
Browse files Browse the repository at this point in the history
  • Loading branch information
milouk committed Oct 17, 2024
1 parent 37cd0dd commit 881482e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 881482e

Please sign in to comment.