« get me outta code hell

write: static-build: gently log failed content functions & continue - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/write/build-modes
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-08-21 22:14:34 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-08-21 22:27:06 -0300
commit98133431c801a823f3430b0e178c56350e12622c (patch)
tree89ad4a65c161613a58a61c31ee373605d1fe96a1 /src/write/build-modes
parent3adf33b567c53e79ce45a36031b29da719fb2377 (diff)
write: static-build: gently log failed content functions & continue
Diffstat (limited to 'src/write/build-modes')
-rw-r--r--src/write/build-modes/static-build.js38
1 files changed, 30 insertions, 8 deletions
diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js
index 2210dfe7..192b7966 100644
--- a/src/write/build-modes/static-build.js
+++ b/src/write/build-modes/static-build.js
@@ -17,6 +17,7 @@ import {serializeThings} from '#serialize';
 import {empty, queue, withEntries} from '#sugar';
 
 import {
+  fileIssue,
   logError,
   logInfo,
   logWarn,
@@ -98,6 +99,7 @@ export async function go({
   developersComment,
   getSizeOfAdditionalFile,
   getSizeOfImageFile,
+  niceShowAggregate,
 }) {
   const outputPath = cliOptions['out-path'] || process.env.HSMUSIC_OUT;
   const appendIndexHTML = cliOptions['append-index-html'] ?? false;
@@ -253,6 +255,8 @@ export async function go({
   ));
   */
 
+  let errored = false;
+
   const contentDependencies = await quickLoadContentDependencies();
 
   const perLanguageFn = async (language, i, entries) => {
@@ -303,14 +307,22 @@ export async function go({
           wikiData,
         });
 
-        const topLevelResult =
-          quickEvaluate({
-            contentDependencies,
-            extraDependencies: {...bound, appendIndexHTML},
-
-            name: page.contentFunction.name,
-            args: page.contentFunction.args ?? [],
-          });
+        let topLevelResult;
+        try {
+          topLevelResult =
+            quickEvaluate({
+              contentDependencies,
+              extraDependencies: {...bound, appendIndexHTML},
+
+              name: page.contentFunction.name,
+              args: page.contentFunction.args ?? [],
+            });
+        } catch (error) {
+          logError`\rError generating page: ${pathname}`;
+          niceShowAggregate(error);
+          errored = true;
+          return;
+        }
 
         const {pageHTML, oEmbedJSON} = html.resolve(topLevelResult);
 
@@ -358,6 +370,16 @@ export async function go({
 
   // The single most important step.
   logInfo`Written!`;
+
+  if (errored) {
+    logWarn`The code generating content for some pages ended up erroring.`;
+    logWarn`These pages were skipped, so if you ran a build previously and`;
+    logWarn`they didn't error that time, then the old version is still`;
+    logWarn`available - albeit possibly outdated! Please scroll up and send`;
+    logWarn`the HSMusic developers a copy of the errors:`;
+    fileIssue({topMessage: null});
+  }
+
   return true;
 }