mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
chore: Remove special case error handling
This commit is contained in:
parent
85774b7e46
commit
a9818b40b6
@ -9,33 +9,11 @@ import { configureSvgSize } from '../../setupGraphViewbox.js';
|
||||
* @param _text - Mermaid graph definition.
|
||||
* @param id - The text for the error
|
||||
* @param version - The version
|
||||
* @param error - The caught error
|
||||
*/
|
||||
export const draw = (
|
||||
_text: string,
|
||||
id: string,
|
||||
version: string,
|
||||
_diagramObject: unknown,
|
||||
error?: Error
|
||||
) => {
|
||||
export const draw = (_text: string, id: string, version: string) => {
|
||||
log.debug('rendering svg for syntax error\n');
|
||||
const svg: SVG = selectSvgElement(id);
|
||||
const g: Group = svg.append('g');
|
||||
if (error?.message?.includes('KaTeX')) {
|
||||
const title = error.message.split(': ')[0];
|
||||
const body = error.message.slice(title.length + 2).replace('KaTeX parse ', '');
|
||||
g.append('foreignObject')
|
||||
.attr('height', 100)
|
||||
.attr('width', 500)
|
||||
.append('xhtml:div')
|
||||
.style('font-size', '18px')
|
||||
.style('color', '#552222')
|
||||
.html(`<div style="font-size: 26px; margin-bottom: 8px">${title}</div><div>${body}</div>`);
|
||||
svg.attr('height', 100);
|
||||
svg.attr('width', 500);
|
||||
svg.attr('viewBox', '0 0 500 100');
|
||||
return;
|
||||
}
|
||||
|
||||
svg.attr('viewBox', '0 0 2412 512');
|
||||
configureSvgSize(svg, 100, 512, true);
|
||||
|
@ -436,8 +436,8 @@ const render = async function (
|
||||
// Draw the diagram with the renderer
|
||||
try {
|
||||
await diag.renderer.draw(text, id, version, diag);
|
||||
} catch (e: any) {
|
||||
errorRenderer.draw(text, id, version, diag, e);
|
||||
} catch (e) {
|
||||
errorRenderer.draw(text, id, version);
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user