Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

Commit 47aa450

Browse files
committed
Handle error on load/save prefs
1 parent 9585f48 commit 47aa450

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

js/preferences.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,15 @@
5353
* Used as `getAll` if the current browser is Chrome.
5454
*/
5555
getAllChrome(callback) {
56-
chrome.storage.local.get(this.defaults, callback);
56+
chrome.storage.local.get(this.defaults, function(preferences) {
57+
if (chrome.runtime.lastError) {
58+
alert('Error retrieving extension preferences, check console for more information.');
59+
60+
console.error('Error retrieving extension preferences:', chrome.runtime.lastError);
61+
} else {
62+
callback(preferences);
63+
}
64+
});
5765
}
5866

5967
/**
@@ -62,7 +70,13 @@
6270
* Used as `setAll` if the current browser is Chrome.
6371
*/
6472
setAllChrome(preferences) {
65-
chrome.storage.local.set(preferences);
73+
chrome.storage.local.set(preferences, function() {
74+
if (chrome.runtime.lastError) {
75+
alert('Error saving extension preferences, check console for more information.');
76+
77+
console.error('Error saving extension preferences:', chrome.runtime.lastError);
78+
}
79+
});
6680
}
6781
}
6882
}(this));

0 commit comments

Comments
 (0)