Handle errors when getting and setting to localStore.

feature/default_network_editable
Dan 7 years ago
parent 7c4a9c32fa
commit 0164030e56
  1. 14
      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
}

Loading…
Cancel
Save