#3395 Renabling the error graph which is rendered on error

This commit is contained in:
Knut Sveidqvist
2022-09-02 14:05:31 +02:00
parent 98f37d64ea
commit 5584fef1b0
7 changed files with 74 additions and 11 deletions

View File

@@ -31,7 +31,7 @@ import stateRenderer from './diagrams/state/stateRenderer';
import stateRendererV2 from './diagrams/state/stateRenderer-v2';
import journeyRenderer from './diagrams/user-journey/journeyRenderer';
import Diagram from './Diagram';
import errorRenderer from './errorRenderer';
import errorRenderer from './diagrams/error/errorRenderer';
import { attachFunctions } from './interactionDb';
import { log, setLogLevel } from './logger';
import getStyles from './styles';
@@ -259,7 +259,14 @@ const render = function (id, _txt, cb, container) {
txt = encodeEntities(txt);
// Important that we do not create the diagram until after the directives have been included
const diag = new Diagram(txt);
let diag;
let parseEncounteredException;
try {
diag = new Diagram(txt);
} catch (error) {
diag = new Diagram('error');
parseEncounteredException = error;
}
// Get the tmp element containing the the svg
const element = root.select('#d' + id).node();
const graphType = diag.type;
@@ -404,6 +411,10 @@ const render = function (id, _txt, cb, container) {
select(tmpElementSelector).node().remove();
}
if (parseEncounteredException) {
throw parseEncounteredException;
}
return svgCode;
};