« get me outta code hell

yaml: fix yaml open/read error reporting - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-05-07 13:02:09 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-05-07 13:02:09 -0300
commitabd899d2952eafdcc9969147d2401f77c9d85599 (patch)
tree1765041862da23d178ed2ce81479991a37bfc858 /src
parent93a271b2aa716c0f43efc340c8789c35e53f5041 (diff)
yaml: fix yaml open/read error reporting
Diffstat (limited to 'src')
-rw-r--r--src/data/yaml.js28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/data/yaml.js b/src/data/yaml.js
index b0cc962a..25a1dd0f 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -853,18 +853,28 @@ export async function loadYAMLDocumentsFromDataSteps(dataSteps, {dataPath}) {
   const filePromises =
     fileLists
       .map(files => files
-        .map(async file => {
-          const {result, aggregate} =
-            await loadYAMLDocumentsFromFile(file);
+        .map(file =>
+          loadYAMLDocumentsFromFile(file).then(
+            ({result, aggregate}) => {
+              const close =
+                decorateErrorWithFileFromDataPath(aggregate.close, {dataPath});
 
-          const close =
-            decorateErrorWithFileFromDataPath(aggregate.close, {dataPath});
+              aggregate.close = () =>
+                close({file});
 
-          aggregate.close =
-            () => close({file});
+              return {result, aggregate};
+            },
+            (error) => {
+              const aggregate = {};
 
-          return {result, aggregate};
-        }));
+              annotateErrorWithFile(error, path.relative(dataPath, file));
+
+              aggregate.close = () => {
+                throw error;
+              };
+
+              return {result: [], aggregate};
+            })));
 
   const fileListPromises =
     filePromises