From 776b219c03d058313c7947f9adb788190d5e42e7 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Tue, 8 Aug 2023 00:31:17 +0530 Subject: [PATCH] chore: Minor cleanups --- packages/mermaid/src/Diagram.ts | 7 +------ packages/mermaid/src/diagram-api/diagramAPI.ts | 6 +++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/mermaid/src/Diagram.ts b/packages/mermaid/src/Diagram.ts index 4da0a3a66..13fd3232b 100644 --- a/packages/mermaid/src/Diagram.ts +++ b/packages/mermaid/src/Diagram.ts @@ -6,9 +6,7 @@ import { extractFrontMatter } from './diagram-api/frontmatter.js'; import { UnknownDiagramError } from './errors.js'; import { cleanupComments } from './diagram-api/comments.js'; import type { DetailedError } from './utils.js'; -import type { MermaidConfig } from './config.type.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; @@ -62,10 +60,7 @@ export class Diagram { throw this.detectError; } this.db.clear?.(); - if (this.init) { - const config = configApi.getConfig(); - this.init(config); - } + this.init?.(configApi.getConfig()); this.parser.parse(this.text); } diff --git a/packages/mermaid/src/diagram-api/diagramAPI.ts b/packages/mermaid/src/diagram-api/diagramAPI.ts index 7e89d9cd7..3edd982bb 100644 --- a/packages/mermaid/src/diagram-api/diagramAPI.ts +++ b/packages/mermaid/src/diagram-api/diagramAPI.ts @@ -69,11 +69,11 @@ export const getDiagram = (name: string): DiagramDefinition => { if (name in diagrams) { return diagrams[name]; } - throw new Error(`Diagram ${name} not found.`); + throw new DiagramNotFoundError(name); }; export class DiagramNotFoundError extends Error { - constructor(message: string) { - super(`Diagram ${message} not found.`); + constructor(name: string) { + super(`Diagram ${name} not found.`); } }