From 4cadb3e1455e6438b0b7c530d509cddca5f3e1c6 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Thu, 21 Nov 2024 16:03:11 -0500 Subject: [PATCH] PubMed Central: Throw when PMC returns error Prevent silent failures when the backend is having issues (as it is right now); this allows a fallback to EM, which works quite well. --- PubMed Central.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/PubMed Central.js b/PubMed Central.js index 36edabfd49b..ecde87ecc2d 100644 --- a/PubMed Central.js +++ b/PubMed Central.js @@ -9,7 +9,7 @@ "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", - "lastUpdated": "2024-10-28 02:40:59" + "lastUpdated": "2024-11-21 21:03:01" } /* @@ -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");