From 4eba3396a31ffb13151d5603f2ba9473ef3d7a8c Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 11 Jun 2023 11:42:06 -0300 Subject: infra: annotate errors with name outside fulfillDependencies --- src/content-function.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/content-function.js b/src/content-function.js index c86d55a8..ab9977f2 100644 --- a/src/content-function.js +++ b/src/content-function.js @@ -108,7 +108,7 @@ export function expectDependencies({ wrappedGenerate.fulfilled = true; wrappedGenerate.fulfill = function() { - throw new Error(`All dependencies already fulfilled`); + throw new Error(`All dependencies already fulfilled (${generate.name})`); }; } @@ -127,6 +127,21 @@ export function expectDependencies({ } wrappedGenerate.fulfill ??= function fulfill(dependencies) { + let newlyFulfilledDependencies; + + try { + newlyFulfilledDependencies = + fulfillDependencies({ + dependencies, + expectedContentDependencyKeys, + expectedExtraDependencyKeys, + fulfilledDependencies, + }); + } catch (error) { + error.message += ` (${generate.name})`; + throw error; + } + return expectDependencies({ sprawl, relations, @@ -136,15 +151,9 @@ export function expectDependencies({ expectedContentDependencyKeys, expectedExtraDependencyKeys, - fulfilledDependencies: fulfillDependencies({ - name: generate.name, - dependencies, - - expectedContentDependencyKeys, - expectedExtraDependencyKeys, - fulfilledDependencies, - }), + fulfilledDependencies: newlyFulfilledDependencies, }); + }; Object.assign(wrappedGenerate, { @@ -156,7 +165,6 @@ export function expectDependencies({ } export function fulfillDependencies({ - name, dependencies, expectedContentDependencyKeys, expectedExtraDependencyKeys, @@ -208,7 +216,7 @@ export function fulfillDependencies({ } if (!empty(errors)) { - throw new AggregateError(errors, `Errors fulfilling dependencies for ${name}`); + throw new AggregateError(errors, `Errors fulfilling dependencies`); } return newFulfilledDependencies; -- cgit 1.3.0-6-gf8a5