From 39f521dac10413ec39a7f8a5c086fc067355a951 Mon Sep 17 00:00:00 2001 From: Adrian Vogelsgesang Date: Sat, 19 Oct 2024 03:04:50 +0200 Subject: [PATCH] Fix minor code tidyness issues Fixes #115, #116 --- query-graphs/src/hyper.ts | 3 +-- query-graphs/src/xml.ts | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/query-graphs/src/hyper.ts b/query-graphs/src/hyper.ts index f3c5dbdb..b5e917a6 100644 --- a/query-graphs/src/hyper.ts +++ b/query-graphs/src/hyper.ts @@ -311,11 +311,10 @@ function colorRelativeExecutionTime(state: ConversionState) { // Sets the edge widths, relative to the number of output tuples function setEdgeWidths(state: ConversionState) { - let maxWidth = state.edgeWidths.reduce((p, v) => (p > v.width ? p : v.width), 0); + const maxWidth = state.edgeWidths.reduce((p, v) => (p > v.width ? p : v.width), 0); const minWidth = state.edgeWidths.reduce((p, v) => (p < v.width ? p : v.width), Infinity); if (minWidth == maxWidth) return; const factor = Math.max(maxWidth - minWidth, minWidth); - maxWidth = Math.max(maxWidth, 10); for (const edge of state.edgeWidths) { edge.node.edgeWidth = (edge.width - minWidth) / factor; } diff --git a/query-graphs/src/xml.ts b/query-graphs/src/xml.ts index 0a9b28b7..0c45726a 100644 --- a/query-graphs/src/xml.ts +++ b/query-graphs/src/xml.ts @@ -33,8 +33,10 @@ export function typesafeXMLParse(str: string): ParsedXML { mergeAttrs: false, }); parser.parseString(str, (err: unknown, parsed: ParsedXML) => { - if (err) { - throw new Error("XML parse failed with '" + err + "'."); + if (err instanceof Error) { + throw new Error("XML parse failed with '" + err.message + "'."); + } else if (err) { + throw new Error("XML parse failed."); } else { result = parsed; }