Detect and handle corrupted saves
Opened this issue · 0 comments
ceruleanskis commented
Need to be able to detect corrupted saves and handle them. Right now, corrupted saves crash the game. This seems to stem from the load menu attempting to parse the save game info in order to display it.
Example of a corrupted save attached.
Traceback (most recent call last):
File "mygame/main.py", line 89, in <module>
raise err
File "mygame/main.py", line 80, in <module>
run_game()
File "mygame/main.py", line 62, in run_game
active_scene.handle_input(filtered_events, pressed_keys)
File "mygame/scenes/menu_scene.py", line 67, in handle_input
self.take_menu_action()
File "mygame/scenes/menu_scene.py", line 86, in take_menu_action
self.switch_scene(load_scene.LoadScene())
File "mygame/scenes/load_scene.py", line 26, in __init__
self.menu_items = utilities.save_manager.SaveManager.get_save_list()
File "mygame/utilities/save_manager.py", line 38, in get_save_list
json_data = SaveManager.load_game(path, import_seed=False)
File "mygame/utilities/save_manager.py", line 81, in load_game
json_data = json.load(json_file)
File "/usr/lib64/python3.9/json/__init__.py", line 293, in load
return loads(fp.read(),
File "/usr/lib64/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 22 column 16 (char 398)
Process finished with exit code 1