From 98f37d64eaa91ba34473a1bda6440d3c269f50a3 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Fri, 2 Sep 2022 12:45:22 +0200 Subject: [PATCH] #3395 Fix for lopp stopping at first failure --- src/mermaid.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/mermaid.js b/src/mermaid.js index 3d2092253..4399fc070 100644 --- a/src/mermaid.js +++ b/src/mermaid.js @@ -35,9 +35,6 @@ const init = function () { } catch (e) { log.warn('Syntax Error rendering'); log.warn(e.str); - if (this.parseError) { - this.parseError(e); - } } }; @@ -93,8 +90,10 @@ const initThrowsErrors = function () { const idGenerator = new utils.initIdGenerator(conf.deterministicIds, conf.deterministicIDSeed); let txt; + const errors = []; for (let i = 0; i < nodes.length; i++) { + log.info('Rendering diagram: ' + nodes[i].id, i); // element is the current div with mermaid class const element = nodes[i]; @@ -134,10 +133,16 @@ const initThrowsErrors = function () { element ); } catch (error) { - log.warn('Catching Error (bootstrap)'); - throw { error, message: error.str }; + log.warn('Catching Error (bootstrap)', error); + if (typeof mermaid.parseError === 'function') { + mermaid.parseError({ error, str: error.str, hash: error.hash, message: error.str }); + } + errors.push({ error, str: error.str, hash: error.hash, message: error.str }); } } + if (errors.length > 0) { + throw errors[0]; + } }; const initialize = function (config) {