Skip to content

Commit

Permalink
Merge pull request #73 from kavi87/fix-68-json-parse-error
Browse files Browse the repository at this point in the history
Handle possible JSON parse error in method state of StateService
  • Loading branch information
kavi87 committed Apr 14, 2016
2 parents a608e82 + 420e42b commit d49196c
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 d49196c

Please sign in to comment.