« get me outta code hell

html: trace line where tag is created - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/util/html.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-12-31 22:52:00 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-01-03 20:45:45 -0400
commita98f2af3d08c5566c188a79bc75c7168d2b555be (patch)
tree3044837278ec4dff8c689f9741136af72776f481 /src/util/html.js
parent1a62a7345b73fbf31b084577ae78379dc1585813 (diff)
html: trace line where tag is created
Diffstat (limited to 'src/util/html.js')
-rw-r--r--src/util/html.js28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/util/html.js b/src/util/html.js
index 2229394..6981966 100644
--- a/src/util/html.js
+++ b/src/util/html.js
@@ -194,10 +194,14 @@ export class Tag {
   #content = null;
   #attributes = null;
 
+  #traceError = null;
+
   constructor(tagName, attributes, content) {
     this.tagName = tagName;
     this.attributes = attributes;
     this.content = content;
+
+    this.#traceError = new Error();
   }
 
   clone() {
@@ -430,10 +434,26 @@ export class Tag {
         itemContent = item.toString();
       } catch (caughtError) {
         const indexPart = colors.yellow(`child #${index + 1}`);
-        throw new Error(
-          `Error in ${indexPart} ` +
-          `of ${inspect(this, {compact: true})}`,
-          {cause: caughtError});
+
+        const error =
+          new Error(
+            `Error in ${indexPart} ` +
+            `of ${inspect(this, {compact: true})}`,
+            {cause: caughtError});
+
+        error[Symbol.for(`hsmusic.aggregate.alwaysTrace`)] = true;
+        error[Symbol.for(`hsmusic.aggregate.traceFrom`)] = this.#traceError;
+
+        error[Symbol.for(`hsmusic.aggregate.unhelpfulTraceLines`)] = [
+          /content-function\.js/,
+          /util\/html\.js/,
+        ];
+
+        error[Symbol.for(`hsmusic.aggregate.helpfulTraceLines`)] = [
+          /content\/dependencies\/(.*\.js:.*(?=\)))/,
+        ];
+
+        throw error;
       }
 
       if (!itemContent) {