diff options
Diffstat (limited to 'ext/bg/js')
-rw-r--r-- | ext/bg/js/audio.js | 4 | ||||
-rw-r--r-- | ext/bg/js/options.js | 4 | ||||
-rw-r--r-- | ext/bg/js/request.js | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/ext/bg/js/audio.js b/ext/bg/js/audio.js index 2e5db7cc..44da51d1 100644 --- a/ext/bg/js/audio.js +++ b/ext/bg/js/audio.js @@ -57,7 +57,7 @@ async function audioBuildUrl(definition, mode, cache={}) { const xhr = new XMLHttpRequest(); xhr.open('POST', 'https://www.japanesepod101.com/learningcenter/reference/dictionary_post'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); - xhr.addEventListener('error', () => reject('Failed to scrape audio data')); + xhr.addEventListener('error', () => reject(new Error('Failed to scrape audio data'))); xhr.addEventListener('load', () => { cache[definition.expression] = xhr.responseText; resolve(xhr.responseText); @@ -87,7 +87,7 @@ async function audioBuildUrl(definition, mode, cache={}) { } else { const xhr = new XMLHttpRequest(); xhr.open('GET', `https://jisho.org/search/${definition.expression}`); - xhr.addEventListener('error', () => reject('Failed to scrape audio data')); + xhr.addEventListener('error', () => reject(new Error('Failed to scrape audio data'))); xhr.addEventListener('load', () => { cache[definition.expression] = xhr.responseText; resolve(xhr.responseText); diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index 2c9de1ec..a2ab8877 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -402,7 +402,7 @@ function optionsLoad() { chrome.storage.local.get(['options'], store => { const error = chrome.runtime.lastError; if (error) { - reject(error); + reject(new Error(error)); } else { resolve(store.options); } @@ -431,7 +431,7 @@ function optionsSave(options) { chrome.storage.local.set({options: JSON.stringify(options)}, () => { const error = chrome.runtime.lastError; if (error) { - reject(error); + reject(new Error(error)); } else { resolve(); } diff --git a/ext/bg/js/request.js b/ext/bg/js/request.js index e4359863..3afc1506 100644 --- a/ext/bg/js/request.js +++ b/ext/bg/js/request.js @@ -22,7 +22,7 @@ function requestJson(url, action, params) { const xhr = new XMLHttpRequest(); xhr.overrideMimeType('application/json'); xhr.addEventListener('load', () => resolve(xhr.responseText)); - xhr.addEventListener('error', () => reject('Failed to connect')); + xhr.addEventListener('error', () => reject(new Error('Failed to connect'))); xhr.open(action, url); if (params) { xhr.send(JSON.stringify(params)); @@ -34,7 +34,7 @@ function requestJson(url, action, params) { return JSON.parse(responseText); } catch (e) { - return Promise.reject('Invalid response'); + return Promise.reject(new Error('Invalid response')); } }); } |