chore: Remove special case error handling

This commit is contained in:
Sidharth Vinod 2023-12-07 01:27:54 +05:30
parent 85774b7e46
commit a9818b40b6
No known key found for this signature in database
GPG Key ID: FB5CCD378D3907CD
2 changed files with 3 additions and 25 deletions

View File

@ -9,33 +9,11 @@ import { configureSvgSize } from '../../setupGraphViewbox.js';
* @param _text - Mermaid graph definition. * @param _text - Mermaid graph definition.
* @param id - The text for the error * @param id - The text for the error
* @param version - The version * @param version - The version
* @param error - The caught error
*/ */
export const draw = ( export const draw = (_text: string, id: string, version: string) => {
_text: string,
id: string,
version: string,
_diagramObject: unknown,
error?: Error
) => {
log.debug('rendering svg for syntax error\n'); log.debug('rendering svg for syntax error\n');
const svg: SVG = selectSvgElement(id); const svg: SVG = selectSvgElement(id);
const g: Group = svg.append('g'); 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'); svg.attr('viewBox', '0 0 2412 512');
configureSvgSize(svg, 100, 512, true); configureSvgSize(svg, 100, 512, true);

View File

@ -436,8 +436,8 @@ const render = async function (
// Draw the diagram with the renderer // Draw the diagram with the renderer
try { try {
await diag.renderer.draw(text, id, version, diag); await diag.renderer.draw(text, id, version, diag);
} catch (e: any) { } catch (e) {
errorRenderer.draw(text, id, version, diag, e); errorRenderer.draw(text, id, version);
throw e; throw e;
} }