From 55e8f7914b4c4eb5cfced248cd07cadcf69aba3f Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 15 Dec 2021 17:21:26 -0500 Subject: [PATCH] Handle style errors in CSL Preview window Keep going, and log the error --- chrome/content/zotero/tools/cslpreview.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/tools/cslpreview.js b/chrome/content/zotero/tools/cslpreview.js index 5482d2c063..b434f3d2ab 100644 --- a/chrome/content/zotero/tools/cslpreview.js +++ b/chrome/content/zotero/tools/cslpreview.js @@ -60,11 +60,19 @@ var Zotero_CSL_Preview = new function() { if (style.source) { continue; } - Zotero.debug("Generate Bib for " + style.title); - var cite = generateBibliography(style); - if (cite) { + Zotero.debug("Generate bibliography for " + style.title); + let bib; + let err = false; + try { + bib = generateBibliography(style); + } + catch (e) { + err = e; + Zotero.logError(e); + } + if (bib || err) { str += '

' + style.title + '

'; - str += cite; + str += bib || `

${Zotero.Utilities.htmlSpecialChars(err)}

`; str += '
'; } }