From 25a8a5f1c0145c88401da8930aace1feedee0cf1 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 23 Jun 2023 18:22:13 -0300 Subject: infra: log content function spec errors more cleanly --- src/content-function.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/content-function.js') 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 -- cgit 1.3.0-6-gf8a5