« get me outta code hell

infra: early error when relation() called w/ unlisted dependency - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content-function.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-06-02 09:37:41 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-06-02 09:37:41 -0300
commit0f0b19c6027e289f5fdce039ebabf52ee3cc9fc8 (patch)
tree9349deeda6d9a3fadff976ca221a1d3d7c98191c /src/content-function.js
parent405e52004060d6db628010c8593d5663ea1f3032 (diff)
infra: early error when relation() called w/ unlisted dependency
Diffstat (limited to 'src/content-function.js')
-rw-r--r--src/content-function.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/content-function.js b/src/content-function.js
index 921b5bc..3536d5a 100644
--- a/src/content-function.js
+++ b/src/content-function.js
@@ -219,6 +219,8 @@ export function getRelationsTree(dependencies, contentFunctionName, wikiData, ..
       return null;
     }
 
+    const listedDependencies = new Set(contentFunction.contentDependencies);
+
     // TODO: Evaluating a sprawl might belong somewhere better than here, lol...
     const sprawl =
       (contentFunction.sprawl
@@ -233,6 +235,10 @@ export function getRelationsTree(dependencies, contentFunctionName, wikiData, ..
     })();
 
     const relationFunction = (name, ...args) => {
+      if (!listedDependencies.has(name)) {
+        throw new Error(`Called relation('${name}') but ${contentFunctionName} doesn't list that dependency`);
+      }
+
       const relationSymbol = Symbol(relationSymbolMessage(name));
       relationSlots[relationSymbol] = {name, args};
       return {[relationIdentifier]: relationSymbol};