Skip to content

Commit

Permalink
fix: 🐛 Catch errors when removing cycles
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Jul 24, 2022
1 parent b02f3d5 commit 563129c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
19 changes: 10 additions & 9 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/Utils/graphUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
});

Expand Down

0 comments on commit 563129c

Please sign in to comment.