Clean up code from SingleFile error handling fix
This commit is contained in:
parent
1c5cefaffd
commit
37cdba6f40
1 changed files with 8 additions and 8 deletions
|
@ -575,8 +575,8 @@ Zotero.Utilities.Internal = {
|
|||
const xhrRequest = new XMLHttpRequest();
|
||||
xhrRequest.withCredentials = true;
|
||||
xhrRequest.responseType = "arraybuffer";
|
||||
xhrRequest.onerror = (e) => {
|
||||
let error = e.detail;
|
||||
xhrRequest.onerror = () => {
|
||||
let error = { error: `Request failed for ${url}` };
|
||||
onDone(Components.utils.cloneInto(error, sandbox));
|
||||
};
|
||||
xhrRequest.onreadystatechange = () => {
|
||||
|
@ -591,7 +591,7 @@ Zotero.Utilities.Internal = {
|
|||
onDone(Components.utils.cloneInto(res, sandbox));
|
||||
}
|
||||
else {
|
||||
let error = 'Bad Status or Length';
|
||||
let error = { error: 'Bad Status or Length' };
|
||||
onDone(Components.utils.cloneInto(error, sandbox));
|
||||
}
|
||||
}
|
||||
|
@ -615,13 +615,13 @@ Zotero.Utilities.Internal = {
|
|||
catch (error) {
|
||||
let response = await new Promise((resolve, reject) => {
|
||||
coFetch(url, (response) => {
|
||||
if (typeof response === 'object') {
|
||||
resolve(response);
|
||||
}
|
||||
else {
|
||||
if (response.error) {
|
||||
Zotero.debug("Error retrieving url: " + url);
|
||||
Zotero.debug(response);
|
||||
reject(new Error(response));
|
||||
reject(new Error(response.error));
|
||||
}
|
||||
else {
|
||||
resolve(response);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue