summaryrefslogtreecommitdiff
path: root/ext/js/background/backend.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/background/backend.js')
-rw-r--r--ext/js/background/backend.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js
index b25b6033..c0f286f8 100644
--- a/ext/js/background/backend.js
+++ b/ext/js/background/backend.js
@@ -1803,6 +1803,8 @@ class Backend {
reading
));
} catch (e) {
+ const error = this._getAudioDownloadError(e);
+ if (error !== null) { throw error; }
// No audio
return null;
}
@@ -1894,6 +1896,28 @@ class Backend {
return {results, errors};
}
+ _getAudioDownloadError(error) {
+ if (isObject(error.data)) {
+ const {errors} = error.data;
+ if (Array.isArray(errors)) {
+ for (const error2 of errors) {
+ if (!isObject(error2.data)) { continue; }
+ const {details} = error2.data;
+ if (!isObject(details)) { continue; }
+ if (details.error === 'net::ERR_FAILED') {
+ // This is potentially an error due to the extension not having enough URL privileges.
+ // The message logged to the console looks like this:
+ // Access to fetch at '<URL>' from origin 'chrome-extension://<ID>' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
+ const result = new Error('Audio download failed due to possible extension permissions error');
+ result.data = {errors};
+ return result;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
_generateAnkiNoteMediaFileName(prefix, extension, timestamp, definitionDetails) {
let fileName = prefix;