« get me outta code hell

upd8: improve logging & status around search - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/upd8.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-05-30 21:01:52 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-05-31 12:11:57 -0300
commitaa3fa649b9ea8efb54de6cfb63fe7d5acbff8a03 (patch)
treec14dbd35dfa2bbb3da88968a0a217bc806288a6e /src/upd8.js
parent0807f6907218ff20cb1f620107473c91ca78865c (diff)
upd8: improve logging & status around search
Diffstat (limited to 'src/upd8.js')
-rwxr-xr-xsrc/upd8.js42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/upd8.js b/src/upd8.js
index 06b8b64c..3ac9dcc7 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -1491,19 +1491,39 @@ async function main() {
       timeStart: Date.now(),
     });
 
-    await writeSearchData({
-      thumbsCache,
-      urls,
-      wikiCachePath,
-      wikiData,
-    });
+    try {
+      await writeSearchData({
+        thumbsCache,
+        urls,
+        wikiCachePath,
+        wikiData,
+      });
 
-    logInfo`Search data successfully written.`;
+      logInfo`Search data successfully written - nice!`;
+      paragraph = false;
 
-    Object.assign(stepStatusSummary.buildSearchIndex, {
-      status: STATUS_DONE_CLEAN,
-      timeEnd: Date.now(),
-    });
+      Object.assign(stepStatusSummary.buildSearchIndex, {
+        status: STATUS_DONE_CLEAN,
+        timeEnd: Date.now(),
+      });
+    } catch (error) {
+      if (!paragraph) console.log('');
+      niceShowAggregate(error);
+
+      logError`There was an error preparing or writing search data.`;
+      fileIssue();
+      logWarn`Any existing search data will be reused, and search may be`;
+      logWarn`generally dysfunctional. The site should work otherwise, though!`;
+
+      console.log('');
+      paragraph = true;
+
+      Object.assign(stepStatusSummary.buildSearchIndex, {
+        status: STATUS_HAS_WARNINGS,
+        annotation: `see log for details`,
+        timeEnd: Date.now(),
+      });
+    }
   }
 
   // Filter out any things with duplicate directories throughout the data,