« get me outta code hell

html: show html layout in stringification error trace - 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>2023-12-30 00:02:51 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-12-30 12:29:52 -0400
commit8d3cf8442954113f52949b430152fe2d47784a49 (patch)
tree2f43be4ac077088b61b72310e2d5e14ac82ed18d
parentc8aa73d6ac9401a9ffe918347202139cf63c41ab (diff)
html: show html layout in stringification error trace
-rw-r--r--src/util/html.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/util/html.js b/src/util/html.js
index 16da6d73..06afbb4f 100644
--- a/src/util/html.js
+++ b/src/util/html.js
@@ -404,7 +404,17 @@ export class Tag {
     let content = '';
 
     for (const [index, item] of this.content.entries()) {
-      const itemContent = item.toString();
+      let itemContent;
+
+      try {
+        itemContent = item.toString();
+      } catch (caughtError) {
+        throw new Error(
+          `Error stringifying child #${index + 1} ` +
+          `of ${inspect(this, {compact: true})}: ` +
+          inspect(item, {compact: true}),
+          {cause: caughtError});
+      }
 
       if (!itemContent) {
         continue;