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'); } };