#3061 Log handing and other fixes, error handling in diagram creation

This commit is contained in:
Knut Sveidqvist
2022-09-26 10:44:18 +02:00
parent ebdec77c88
commit a928120bec
10 changed files with 101 additions and 95 deletions

View File

@@ -15,33 +15,19 @@ export class Diagram {
this.type = detectType(txt, cnf);
const diagram = getDiagram(this.type);
log.debug('Type ' + this.type);
// console.log('Type ' + this.type);
// Setup diagram
this.db = diagram.db;
this.db.clear?.();
this.renderer = diagram.renderer;
this.parser = diagram.parser;
// console.log('Setting db to !', this.db);
this.parser.parser.yy = this.db;
if (diagram.init) {
diagram.init(cnf);
log.debug('Initialized diagram ' + this.type, cnf);
}
this.txt += '\n';
try {
this.parser.parser.yy.graphType = this.type;
this.parser.parser.yy.parseError = (str: string, hash: string) => {
const error = { str, hash };
throw error;
};
} catch (error) {
log.error('error', error);
}
try {
this.parse(this.txt, parseError);
} catch (error) {
log.error('error', error);
}
this.parse(this.txt, parseError);
}
// eslint-disable-next-line @typescript-eslint/ban-types

View File

@@ -53,7 +53,7 @@ const init = function (
callback?: Function
) {
try {
console.error('Detectors in init', mermaid.detectors); // eslint-disable-line
log.info('Detectors in init', mermaid.detectors); // eslint-disable-line
mermaid.detectors.forEach(({ id, detector }) => {
addDetector(id, detector);
});