From a98f2af3d08c5566c188a79bc75c7168d2b555be Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 31 Dec 2023 22:52:00 -0400 Subject: html: trace line where tag is created --- src/util/html.js | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'src/util') 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) { -- cgit 1.3.0-6-gf8a5