« get me outta code hell

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:
Diffstat (limited to 'src/content-function.js')
-rw-r--r--src/content-function.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/content-function.js b/src/content-function.js
index 18092707..70e7be38 100644
--- a/src/content-function.js
+++ b/src/content-function.js
@@ -4,6 +4,8 @@ import {
   setIntersection,
 } from './util/sugar.js';
 
+export class ContentFunctionSpecError extends Error {}
+
 export default function contentFunction({
   contentDependencies = [],
   extraDependencies = [],
@@ -25,19 +27,19 @@ export default function contentFunction({
     setIntersection(expectedContentDependencyKeys, expectedExtraDependencyKeys);
 
   if (!empty(overlappingContentExtraDependencyKeys)) {
-    throw new Error(`Overlap in content and extra dependency keys: ${[...overlappingContentExtraDependencyKeys].join(', ')}`);
+    throw new ContentFunctionSpecError(`Overlap in content and extra dependency keys: ${[...overlappingContentExtraDependencyKeys].join(', ')}`);
   }
 
   if (!generate) {
-    throw new Error(`Expected generate function`);
+    throw new ContentFunctionSpecError(`Expected generate function`);
   }
 
   if (sprawl && !expectedExtraDependencyKeys.has('wikiData')) {
-    throw new Error(`Content functions which sprawl must specify wikiData in extraDependencies`);
+    throw new ContentFunctionSpecError(`Content functions which sprawl must specify wikiData in extraDependencies`);
   }
 
   if (slots && !expectedExtraDependencyKeys.has('html')) {
-    throw new Error(`Content functions with slots must specify html in extraDependencies`);
+    throw new ContentFunctionSpecError(`Content functions with slots must specify html in extraDependencies`);
   }
 
   // Pass all the details to expectDependencies, which will recursively build