Read Aloud: Fix 402 handling

This commit is contained in:
Abe Jellinek 2026-05-22 10:29:20 -04:00
parent e2f33fbfe8
commit fbdb7c1f30

View file

@ -672,8 +672,8 @@ Zotero.Sync.APIClient.prototype = {
let method;
let url;
let options = {
// Could be a blob (audio bytes) or an application/json envelope with `audioURL`
// and `timestamps`; we inspect the Content-Type before parsing.
// Could be audio bytes or a JSON { audioURL, timestamps } object
// Inspect the Content-Type before parsing
responseType: "arraybuffer",
errorDelayMax: 8000,
};
@ -715,7 +715,13 @@ Zotero.Sync.APIClient.prototype = {
let error;
if (e instanceof Zotero.HTTP.UnexpectedStatusException && e.status === 402) {
let body = await e.xmlhttp.response?.text();
let body = null;
try {
body = new TextDecoder().decode(e.xmlhttp.response);
}
catch {
// Ignore
}
error = body === 'daily_limit_exceeded' ? 'daily-limit-exceeded' : 'quota-exceeded';
}
else if (e instanceof Zotero.HTTP.BrowserOfflineException) {