Throw translation error on >=400 status code for doGet()/doPost()
Previously the handler would be called even on error pages, which often meant that an import translator (e.g., BibTeX) would fail to find anything on the page and the save popup would just close silently. The popup will now show an error message as soon as the error occurs.
This commit is contained in:
parent
85667429a8
commit
2652fac24b
1 changed files with 10 additions and 0 deletions
|
@ -326,6 +326,11 @@ Zotero.Utilities.Translate.prototype.doGet = function(urls, processor, done, res
|
|||
|
||||
translate.incrementAsyncProcesses("Zotero.Utilities.Translate#doGet");
|
||||
var xmlhttp = Zotero.HTTP.doGet(url, function(xmlhttp) {
|
||||
if (xmlhttp.status >= 400) {
|
||||
translate.complete(false, `HTTP GET ${url} failed with status code ${xmlhttp.status}`);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if(processor) {
|
||||
processor(xmlhttp.responseText, xmlhttp, url);
|
||||
|
@ -355,6 +360,11 @@ Zotero.Utilities.Translate.prototype.doPost = function(url, body, onDone, header
|
|||
|
||||
translate.incrementAsyncProcesses("Zotero.Utilities.Translate#doPost");
|
||||
var xmlhttp = Zotero.HTTP.doPost(url, body, function(xmlhttp) {
|
||||
if (xmlhttp.status >= 400) {
|
||||
translate.complete(false, `HTTP POST ${url} failed with status code ${xmlhttp.status}`);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
onDone(xmlhttp.responseText, xmlhttp);
|
||||
translate.decrementAsyncProcesses("Zotero.Utilities.Translate#doPost");
|
||||
|
|
Loading…
Reference in a new issue