From 6ff5c3e6183fe5d7fb619c633454b70b526ad2a6 Mon Sep 17 00:00:00 2001 From: Ross Keenan Date: Fri, 13 Aug 2021 12:44:01 +0200 Subject: [PATCH] fix(Stats View): :goal_net: Error handling in wordCounts --- src/Components/TrailGrid.svelte | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Components/TrailGrid.svelte b/src/Components/TrailGrid.svelte index 56ad8b01..4c1626f4 100644 --- a/src/Components/TrailGrid.svelte +++ b/src/Components/TrailGrid.svelte @@ -43,13 +43,18 @@ const allCells = [...new Set(sortedTrails.reduce((a, b) => [...a, ...b]))]; const wordCounts: { [cell: string]: number } = {}; - allCells.forEach( - (cell) => - (wordCounts[cell] = app.metadataCache.getFirstLinkpathDest( + allCells.forEach((cell) => { + try { + wordCounts[cell] = app.metadataCache.getFirstLinkpathDest( cell, currFile.path - ).stat.size) - ); + ).stat.size; + } catch (error) { + console.log(error); + console.log({ currFile }); + wordCounts[cell] = 0 + } + }); // const data: {[cell: string]: number} = {} // allCells.forEach(cell => data[cell] = app.metadataCache.getFileCache(app.metadataCache.getFirstLinkpathDest(cell, currFile.path))?.links.length ?? 0);