Skip to content

Commit

Permalink
Handle possible JSON parse error in method state of StateService
Browse files Browse the repository at this point in the history
  • Loading branch information
kavi87 committed Apr 14, 2016
1 parent a608e82 commit 420e42b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ define([
}

if (typeof states[namespace] === 'undefined') {
states[namespace] = angular.fromJson(storage.getItem(prefix)) || {};
try {
states[namespace] = angular.fromJson(storage.getItem(prefix)) || {};
} catch (e) {
states[namespace] = {};
}
}
if (typeof states[namespace][key] === 'undefined') {
states[namespace][key] = defaultvalue;
Expand Down

0 comments on commit 420e42b

Please sign in to comment.