diff --git a/package-lock.json b/package-lock.json index 1cdabc3..a4794d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "traktflix", - "version": "2.0.10", + "version": "2.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 14a938a..9ca7d8c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "traktflix", - "version": "2.1.0", + "version": "2.1.1", "description": "A Trakt.tv scrobbler for Netflix.", "author": "tegon", "private": true, diff --git a/src/class/Request.js b/src/class/Request.js index d4f933e..039129f 100644 --- a/src/class/Request.js +++ b/src/class/Request.js @@ -7,6 +7,9 @@ class Request { if (!Shared.isBackgroundPage() && !options.url.match(location.host)) { try { const response = await browser.runtime.sendMessage({ type: `request`, options: JSON.stringify(options) }); + if (response.error) { + throw response; + } options.success(response); } catch (error) { options.error(error.status, error.responseText, error.options); diff --git a/src/modules/background/index.js b/src/modules/background/index.js index adf2819..ab04403 100644 --- a/src/modules/background/index.js +++ b/src/modules/background/index.js @@ -38,7 +38,7 @@ if (chrome && chrome.declarativeContent) { } browser.runtime.onMessage.addListener((request, sender) => { - return new Promise(async (resolve, reject) => { + return new Promise(async resolve => { switch (request.type) { case `getApiDefs`: // noinspection JSIgnoredPromiseFromCall @@ -113,8 +113,9 @@ browser.runtime.onMessage.addListener((request, sender) => { try { const response = await Request.sendAndWait(options); resolve(response); - } catch (error) { - reject(error); + } catch (response) { + response.error = true; + resolve(response); } return; }