From 37cdba6f40ad9460c19a9cbbead32d14621767fe Mon Sep 17 00:00:00 2001 From: Fletcher Hazlehurst Date: Mon, 28 Sep 2020 11:48:53 -0700 Subject: [PATCH] Clean up code from SingleFile error handling fix --- .../content/zotero/xpcom/utilities_internal.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index 2359c39ebb..ab2d23740b 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -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); } }); });