« get me outta code hell

read static pages from directory - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2022-08-17 22:02:37 -0300
committer(quasar) nebula <qznebula@protonmail.com>2022-08-17 22:02:37 -0300
commitcb3edb0b2bdea87cd29559e4a9df2e7c062a4df7 (patch)
tree5caf4ce09c65e926d7af31caf66c0bde9b779a85 /src/util
parente7b31abecc99a8c19990b6b24ad14ee427bf6922 (diff)
read static pages from directory
Diffstat (limited to 'src/util')
-rw-r--r--src/util/io.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/util/io.js b/src/util/io.js
index 4a6e95f3..cfd6708d 100644
--- a/src/util/io.js
+++ b/src/util/io.js
@@ -10,7 +10,14 @@ export async function findFiles(dataPath, {
   filter = () => true,
   joinParentDirectory = true,
 } = {}) {
-  return (await readdir(dataPath))
+  let files;
+  try {
+    files = await readdir(dataPath);
+  } catch (error) {
+    throw new AggregateError([error], `Failed to list files from ${dataPath}`);
+  }
+
+  return files
     .filter((file) => filter(file))
     .map((file) => (joinParentDirectory ? path.join(dataPath, file) : file));
 }