From 420e42ba53e89c317f5a4f7d39573559e37cb071 Mon Sep 17 00:00:00 2001 From: kavi87 Date: Thu, 14 Apr 2016 15:33:29 +0200 Subject: [PATCH] Handle possible JSON parse error in method state of StateService --- modules/env.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/env.js b/modules/env.js index 3d0bdae..4835c9f 100644 --- a/modules/env.js +++ b/modules/env.js @@ -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;