mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-19 20:24:16 +01:00
#3061 Log handing and other fixes, error handling in diagram creation
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user