diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-06-23 18:22:13 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-06-23 18:22:13 -0300 |
commit | 25a8a5f1c0145c88401da8930aace1feedee0cf1 (patch) | |
tree | 7793a6c8ab66508d806d329579d87e1453075c0b /src/content-function.js | |
parent | 53395fa815cdf6f912e78f80bef8908005186270 (diff) |
infra: log content function spec errors more cleanly
Diffstat (limited to 'src/content-function.js')
-rw-r--r-- | src/content-function.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/content-function.js b/src/content-function.js index 1809270..70e7be3 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 |