mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-26 02:39:41 +02:00
chore: Minor cleanups
This commit is contained in:
@@ -6,9 +6,7 @@ import { extractFrontMatter } from './diagram-api/frontmatter.js';
|
|||||||
import { UnknownDiagramError } from './errors.js';
|
import { UnknownDiagramError } from './errors.js';
|
||||||
import { cleanupComments } from './diagram-api/comments.js';
|
import { cleanupComments } from './diagram-api/comments.js';
|
||||||
import type { DetailedError } from './utils.js';
|
import type { DetailedError } from './utils.js';
|
||||||
import type { MermaidConfig } from './config.type.js';
|
|
||||||
import type { DiagramDefinition } from './diagram-api/types.js';
|
import type { DiagramDefinition } from './diagram-api/types.js';
|
||||||
import { D } from 'vitest/dist/types-198fd1d9.js';
|
|
||||||
|
|
||||||
export type ParseErrorFunction = (err: string | DetailedError | unknown, hash?: any) => void;
|
export type ParseErrorFunction = (err: string | DetailedError | unknown, hash?: any) => void;
|
||||||
|
|
||||||
@@ -62,10 +60,7 @@ export class Diagram {
|
|||||||
throw this.detectError;
|
throw this.detectError;
|
||||||
}
|
}
|
||||||
this.db.clear?.();
|
this.db.clear?.();
|
||||||
if (this.init) {
|
this.init?.(configApi.getConfig());
|
||||||
const config = configApi.getConfig();
|
|
||||||
this.init(config);
|
|
||||||
}
|
|
||||||
this.parser.parse(this.text);
|
this.parser.parse(this.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -69,11 +69,11 @@ export const getDiagram = (name: string): DiagramDefinition => {
|
|||||||
if (name in diagrams) {
|
if (name in diagrams) {
|
||||||
return diagrams[name];
|
return diagrams[name];
|
||||||
}
|
}
|
||||||
throw new Error(`Diagram ${name} not found.`);
|
throw new DiagramNotFoundError(name);
|
||||||
};
|
};
|
||||||
|
|
||||||
export class DiagramNotFoundError extends Error {
|
export class DiagramNotFoundError extends Error {
|
||||||
constructor(message: string) {
|
constructor(name: string) {
|
||||||
super(`Diagram ${message} not found.`);
|
super(`Diagram ${name} not found.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user