aboutsummaryrefslogtreecommitdiff
path: root/ext/js/background
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/background')
-rw-r--r--ext/js/background/backend.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js
index 698724fc..d88c5853 100644
--- a/ext/js/background/backend.js
+++ b/ext/js/background/backend.js
@@ -307,7 +307,7 @@ class Backend {
}
}
- return yomichan.invokeMessageHandler(messageHandler, params, callback, sender);
+ return invokeMessageHandler(messageHandler, params, callback, sender);
}
_onConnect(port) {
@@ -1563,7 +1563,7 @@ class Backend {
return new Promise((resolve, reject) => {
const callback = (response) => {
try {
- resolve(yomichan.getMessageResponseResult(response));
+ resolve(this._getMessageResponseResult(response));
} catch (error) {
reject(error);
}
@@ -1573,6 +1573,21 @@ class Backend {
});
}
+ _getMessageResponseResult(response) {
+ let error = chrome.runtime.lastError;
+ if (error) {
+ throw new Error(error.message);
+ }
+ if (!isObject(response)) {
+ throw new Error('Tab did not respond');
+ }
+ error = response.error;
+ if (error) {
+ throw deserializeError(error);
+ }
+ return response.result;
+ }
+
async _checkTabUrl(tabId, urlPredicate) {
let tab;
try {