summaryrefslogtreecommitdiffstats
path: root/build.js
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2022-07-11 23:19:07 +0300
committerJan Tuomi <jans.tuomi@gmail.com>2022-07-11 23:19:07 +0300
commit7ea1eb2ffcec40dcb2fcdc737ccfab4c5779b034 (patch)
tree5a66e8e82c3b445001e53910e90f287790d1896d /build.js
parentcf0669ebd4563144c1ba50f62fe71fe6139e7037 (diff)
Add error handling to _gallery read
Diffstat (limited to 'build.js')
-rw-r--r--build.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/build.js b/build.js
index c7b8f39..6a71e22 100644
--- a/build.js
+++ b/build.js
@@ -30,7 +30,18 @@ const htmlTemplate = fs.readFileSync(HTML_TEMP_PATH, "utf-8");
const galleryJsonList = fs.readdirSync(GALLERY_DIR);
const galleryViews = galleryJsonList
- .map((fileName) => fs.readFileSync(path.join(GALLERY_DIR, fileName), "utf-8"))
+ .map((fileName) => {
+ try {
+ return fs.readFileSync(path.join(GALLERY_DIR, fileName), "utf-8");
+ } catch (err) {
+ if (err.message?.includes("ENOENT")) {
+ console.warn("Could not read galleries, using empty list");
+ return []
+ } else {
+ throw err;
+ }
+ }
+ })
.map(JSON.parse)
.map((gallery) => {
const rows = sliceIntoChunks(gallery["images"], gallery["column_count"]);