mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Handle errors when getting and setting to localStore.
This commit is contained in:
parent
7c4a9c32fa
commit
0164030e56
@ -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…
Reference in New Issue
Block a user