Skip to content

Commit

Permalink
PubMed Central: Throw when PMC returns error
Browse files Browse the repository at this point in the history
Prevent silent failures when the backend is having issues (as it is
right now); this allows a fallback to EM, which works quite well.
  • Loading branch information
AbeJellinek committed Nov 21, 2024
1 parent daa4501 commit 4cadb3e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion PubMed Central.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2024-10-28 02:40:59"
"lastUpdated": "2024-11-21 21:03:01"
}

/*
Expand Down Expand Up @@ -141,6 +141,13 @@ function lookupPMCIDs(ids, doc, pdfLink) {

var articles = ZU.xpath(doc, '/pmcarticleset/article');

if (!articles.length) {
let error = ZU.xpathText(doc, '/pmcarticleset/error/Message');
if (error) {
throw new Error(`PMC returned error: ${error}`);
}
}

for (var i in articles) {
var newItem = new Zotero.Item("journalArticle");

Expand Down

0 comments on commit 4cadb3e

Please sign in to comment.