changeset 136:1a648d07d67e

Handle broken (but valid JSON) autosave more gracefully.
author Jeremy Thurgood <firxen@gmail.com>
date Thu, 10 May 2012 19:20:57 +0200
parents 8d1cf98e39b5
children fb8037bc22f1
files gamelib/mainmenu.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/mainmenu.py	Thu May 10 17:07:06 2012 +0200
+++ b/gamelib/mainmenu.py	Thu May 10 19:20:57 2012 +0200
@@ -98,9 +98,12 @@
                 print 'Unable to load the autosave file - skipping'
                 game_data = None
             f.close()
-            self.game_window = LabWindow(self.screen, game_data)
-            if game_data:
-                self.add_resume()
+            try:
+                self.game_window = LabWindow(self.screen, game_data)
+                if game_data:
+                    self.add_resume()
+            except Exception, e:
+                print 'Error loading autosave (%r) - ignoring' % (e,)
         # We stay at the main menu, so the user can can to continue or not
 
     def add_resume(self):