diff options
Handle errors when getting and setting to localStore.
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/background.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js index 280c28d70..88600bf1e 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -57,7 +57,13 @@ async function loadStateFromPersistence () { // fetch from extension store and merge in data if (localStore.isSupported) { - const localData = await localStore.get() + let localData + try { + localData = await localStore.get() + } catch (err) { + log.error('error fetching state from local store:', err) + } + // TODO: handle possible exceptions (https://developer.chrome.com/apps/runtime#property-lastError) versionedData = Object.keys(localData).length > 0 ? localData : versionedData } @@ -113,7 +119,11 @@ function setupController (initState) { function syncDataWithExtension(state) { if (localStore.isSupported) { - localStore.set(state) // TODO: handle possible exceptions (https://developer.chrome.com/apps/runtime#property-lastError) + try { + localStore.set(state) + } catch (err) { + log.error('error setting state in local store:', err) + } } return state } |