« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
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