« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/util/io.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/io.js')
-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));
 }