« get me outta code hell

more useful error when album missing Name field - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2022-01-01 16:07:48 -0400
committer(quasar) nebula <qznebula@protonmail.com>2022-01-01 16:07:48 -0400
commit40d0c09ea64a6e0d3bd93e902a14218a96e95933 (patch)
tree52ed8aab1d2e7ea31d3f5139f36d402f0d8293a9
parent940087d2d2df955d6bdd4b0cdbbf6d35f254c802 (diff)
more useful error when album missing Name field
-rwxr-xr-xsrc/upd8.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/upd8.js b/src/upd8.js
index c9fc1d87..08365c11 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -782,6 +782,11 @@ async function processAlbumDataFile(file) {
     const album = {};
 
     album.name = getBasicField(albumSection, 'Album');
+
+    if (!album.name) {
+        return {error: `The file "${path.relative(dataPath, file)}" is missing the "Album" field - maybe this is a misplaced file instead of album data?`};
+    }
+
     album.artists = getContributionField(albumSection, 'Artists') || getContributionField(albumSection, 'Artist');
     album.wallpaperArtists = getContributionField(albumSection, 'Wallpaper Art');
     album.wallpaperStyle = getMultilineField(albumSection, 'Wallpaper Style');