Permalink
Browse files

Bug 825985 - If we can't parse the settings, use the default ones.

  • Loading branch information...
rik committed Jan 7, 2013
1 parent 550e477 commit 46fc25f35611db6ecff40370e02b9a7e8f97b7e1
Showing with 12 additions and 12 deletions.
  1. +12 −12 apps/costcontrol/js/config_manager.js
@@ -99,20 +99,20 @@ var ConfigManager = (function() {
function requestSettings(callback) {
asyncStorage.getItem(currentICCID, function _wrapGetItem(localSettings) {
// No entry: set defaults
settings = JSON.parse(localSettings, settingsReviver);
if (settings !== null) {
if (callback)
callback(settings);
return;
try {
settings = JSON.parse(localSettings, settingsReviver);
} catch(e) {
// If we can't parse the settings, use the default ones
}
settings = deepCopy(DEFAULT_SETTINGS);
asyncStorage.setItem(currentICCID, JSON.stringify(settings),
function _onceSettingsSet() {
if (callback)
callback(settings);
}
);
if (settings === null) {
settings = deepCopy(DEFAULT_SETTINGS);
asyncStorage.setItem(currentICCID, JSON.stringify(settings));
}
if (callback) {
callback(settings);
}
});
}

0 comments on commit 46fc25f

Please sign in to comment.