From 9302a8b165f67e8de44300cfda8aa26287e9609a Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 30 Dec 2023 09:52:17 -0400 Subject: infra: hook content function generate() into new trace algorithm --- src/content-function.js | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/content-function.js b/src/content-function.js index a3d7b585..f57b606a 100644 --- a/src/content-function.js +++ b/src/content-function.js @@ -124,12 +124,32 @@ export function expectDependencies({ throw new Error(`Expected relations`); } - if (hasDataFunction && hasRelationsFunction) { - return generate(arg1, arg2, ...extraArgs, fulfilledDependencies); - } else if (hasDataFunction || hasRelationsFunction) { - return generate(arg1, ...extraArgs, fulfilledDependencies); - } else { - return generate(...extraArgs, fulfilledDependencies); + try { + if (hasDataFunction && hasRelationsFunction) { + return generate(arg1, arg2, ...extraArgs, fulfilledDependencies); + } else if (hasDataFunction || hasRelationsFunction) { + return generate(arg1, ...extraArgs, fulfilledDependencies); + } else { + return generate(...extraArgs, fulfilledDependencies); + } + } catch (caughtError) { + const error = new Error( + `Error generating content for ${generate.name}`, + {cause: caughtError}); + + error[Symbol.for(`hsmusic.aggregate.alwaysTrace`)] = true; + error[Symbol.for(`hsmusic.aggregate.traceFrom`)] = caughtError; + + error[Symbol.for(`hsmusic.aggregate.unhelpfulTraceLines`)] = [ + /content-function\.js/, + /util\/html\.js/, + ]; + + error[Symbol.for(`hsmusic.aggregate.helpfulTraceLines`)] = [ + /content\/dependencies\/(.*\.js:.*(?=\)))/, + ]; + + throw error; } }; -- cgit 1.3.0-6-gf8a5