fix: Error diagram rendering

This commit is contained in:
Sidharth Vinod
2023-08-17 14:26:04 +05:30
parent 1c8201a204
commit 6334d4ab84
+13 -1
View File
@@ -8,7 +8,19 @@ export const render = async (
): Promise<RenderResult> => {
// Should be able to call this multiple times without any issues.
mermaid.initialize(config);
return await mermaid.render(id, code);
try {
const result = await mermaid.render(id, code);
return result;
} catch {
const errorDiv = document.querySelector(`#d${id}`);
const svg = errorDiv?.innerHTML ?? '';
errorDiv?.remove();
return {
svg,
bindFunctions: undefined
};
}
};
export const parse = async (code: string): Promise<unknown> => {