aboutsummaryrefslogtreecommitdiff
path: root/ext/js/media/audio-downloader.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2022-05-28 21:55:37 -0400
committerGitHub <noreply@github.com>2022-05-28 21:55:37 -0400
commit4e4fa49b0b1fd6ec5a018e742eb9910aa32e7637 (patch)
tree53ff2717de5c0654b0050c58f86fe49b8c89c6a4 /ext/js/media/audio-downloader.js
parent756cfc027696901f0afc9b84bb439c67c8b620ad (diff)
Audio request errors (#2161)
* Generalize _onBeforeSendHeadersAddListener * Simplify filter assignment * Use requestId rather than done * Properly support Firefox addListener without arguments * Add details to fetchAnonymous errors * Refactor * Enable support for no header modifications * Update MV3 support for error details * Expose errors in downloadTermAudio * Throw an error if audio download fails due to potential permissions reasons
Diffstat (limited to 'ext/js/media/audio-downloader.js')
-rw-r--r--ext/js/media/audio-downloader.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/js/media/audio-downloader.js b/ext/js/media/audio-downloader.js
index c2e1742f..0991d14d 100644
--- a/ext/js/media/audio-downloader.js
+++ b/ext/js/media/audio-downloader.js
@@ -51,6 +51,7 @@ class AudioDownloader {
}
async downloadTermAudio(sources, preferredAudioIndex, term, reading) {
+ const errors = [];
for (const source of sources) {
let infoList = await this.getTermAudioInfoList(source, term, reading);
if (typeof preferredAudioIndex === 'number') {
@@ -62,14 +63,16 @@ class AudioDownloader {
try {
return await this._downloadAudioFromUrl(info.url, source.type);
} catch (e) {
- // NOP
+ errors.push(e);
}
break;
}
}
}
- throw new Error('Could not download audio');
+ const error = new Error('Could not download audio');
+ error.data = {errors};
+ throw error;
}
// Private