From d41b7329b3280cfef0de01de519ddad6cddcf41c Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Mon, 29 Jun 2015 17:16:20 -0500 Subject: [PATCH] Show popup error for corrupt teams --- js/storage.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/storage.js b/js/storage.js index 010320163..75112258b 100644 --- a/js/storage.js +++ b/js/storage.js @@ -31,7 +31,16 @@ Storage.loadTeams = function() { this.teams = []; if (window.localStorage) { var teamString = localStorage.getItem('showdown_teams'); - if (teamString) this.teams = JSON.parse(teamString); + if (teamString) { + try { + this.teams = JSON.parse(teamString); + } catch (e) { + app.addPopup(Popup, { + type: 'modal', + htmlMessage: "Your teams are corrupt and could not be loaded. :( We may be able to recover a team from this data:
" + }); + } + } app.trigger('init:loadteams'); } };