aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/util.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-02-05 16:39:40 -0800
committerAlex Yatskov <alex@foosoft.net>2017-02-05 16:39:40 -0800
commit4e3792aba319b52f957c70347e859f677972e4e2 (patch)
tree3ea382513378f852f2126d1113e21061c61adec8 /ext/fg/js/util.js
parent5076b80f9690a12fda23d06b2c3ddd1df08cff56 (diff)
handle content script and background script desync on version update1.0.9
Diffstat (limited to 'ext/fg/js/util.js')
-rw-r--r--ext/fg/js/util.js23
1 files changed, 16 insertions, 7 deletions
diff --git a/ext/fg/js/util.js b/ext/fg/js/util.js
index ef45d08c..ba872467 100644
--- a/ext/fg/js/util.js
+++ b/ext/fg/js/util.js
@@ -19,16 +19,25 @@
function invokeBgApi(action, params) {
return new Promise((resolve, reject) => {
- chrome.runtime.sendMessage({action, params}, ({result, error}) => {
- if (error) {
- reject(error);
- } else {
- resolve(result);
- }
- });
+ try {
+ chrome.runtime.sendMessage({action, params}, ({result, error}) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(result);
+ }
+ });
+ } catch (e) {
+ window.orphaned = true;
+ reject(e.message);
+ }
});
}
+function showError(error) {
+ window.alert(`Error: ${error}`);
+}
+
function isEnabled() {
return invokeBgApi('getEnabled', {});
}