Throw an error if HTTP request yields non-OK in importFromURL()

This commit is contained in:
Simon Kornblith 2015-06-07 16:05:53 -04:00
parent 6935310c75
commit e27d907973

View file

@ -258,6 +258,13 @@ Zotero.Attachments = new function(){
var browser = Zotero.HTTP.processDocuments(
url,
function() {
let channel = browser.docShell.currentDocumentChannel;
if (channel && (channel instanceof Components.interfaces.nsIHttpChannel)) {
if (channel.responseStatus < 200 || channel.responseStatus >= 400) {
deferred.reject(new Error("Invalid response "+channel.responseStatus+" "+channel.responseStatusText+" for '"+url+"'"));
return;
}
}
return Zotero.Attachments.importFromDocument({
libraryID: libraryID,
document: browser.contentDocument,