From 563129c89a5ca832b080b99fc2015dcdda769f67 Mon Sep 17 00:00:00 2001 From: Ross Keenan Date: Sun, 24 Jul 2022 08:42:00 +0200 Subject: [PATCH] fix: :bug: Catch errors when removing cycles --- main.js | 19 ++++++++++--------- src/Utils/graphUtils.ts | 3 ++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/main.js b/main.js index ef1526e6..cb567fd9 100644 --- a/main.js +++ b/main.js @@ -5491,7 +5491,12 @@ function removeCycles(g, startNode) { graphologyTraversal.dfsFromNode(copy, startNode, (n) => { copy.forEachOutNeighbor(n, (t) => { if (t === prevNode && copy.hasEdge(t, prevNode)) { - copy.dropEdge(t, prevNode); + try { + copy.dropEdge(t, prevNode); + } + catch (error) { + console.error(t, prevNode, error); + } } }); prevNode = n; @@ -33894,19 +33899,15 @@ function unproxy(item) { } /** * Given a `dvCache[field]` value, parse the link(s) out of it - * @param {string|string[]|string[][]|dvLink|dvLink[]|Pos|TFile} value - * @param {BCSettings} settings + * @param {string | string[] | string[][] | dvLink | dvLink[] | Pos | TFile} value */ function parseFieldValue(value) { - if (value === undefined) + if (!value) return []; const parsed = []; try { - const rawValuesPreFlat = value; - if (!rawValuesPreFlat) - return []; - if (typeof rawValuesPreFlat === "string") { - const splits = rawValuesPreFlat.match(splitLinksRegex); + if (typeof value === "string") { + const splits = value.match(splitLinksRegex); if (splits !== null) { const linkNames = splits.map((link) => getBaseFromMDPath(link.match(dropHeaderOrAlias)[1])); parsed.push(...linkNames); diff --git a/src/Utils/graphUtils.ts b/src/Utils/graphUtils.ts index e3e5f458..eb2c66ca 100644 --- a/src/Utils/graphUtils.ts +++ b/src/Utils/graphUtils.ts @@ -220,7 +220,8 @@ export function removeCycles(g: Graph, startNode: string) { dfsFromNode(copy, startNode, (n) => { copy.forEachOutNeighbor(n, (t) => { if (t === prevNode && copy.hasEdge(t, prevNode)) { - copy.dropEdge(t, prevNode); + try { copy.dropEdge(t, prevNode) } + catch (error) { console.error(t, prevNode, error) } } });