From 8d3cf8442954113f52949b430152fe2d47784a49 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 30 Dec 2023 00:02:51 -0400 Subject: html: show html layout in stringification error trace --- src/util/html.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/util/html.js') 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; -- cgit 1.3.0-6-gf8a5