aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/util.js
diff options
context:
space:
mode:
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', {});
}