From ddd4f7fe4274e236dcd5159f5a1734669e32f224 Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Mon, 5 Dec 2022 15:17:57 -0500 Subject: [PATCH] fix: add loadContentConfig error classes back --- packages/astro/src/content/utils.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/astro/src/content/utils.ts b/packages/astro/src/content/utils.ts index f0a3610ac35d..c1c626a722f8 100644 --- a/packages/astro/src/content/utils.ts +++ b/packages/astro/src/content/utils.ts @@ -126,6 +126,9 @@ export function parseFrontmatter(fileContents: string, filePath: string) { } } +export class NotFoundError extends TypeError {} +export class ZodParseError extends TypeError {} + export async function loadContentConfig({ settings, }: { @@ -145,7 +148,7 @@ export async function loadContentConfig({ try { unparsedConfig = await tempConfigServer.ssrLoadModule(paths.config.pathname); } catch { - return new Error('Failed to resolve content config.'); + return new NotFoundError('Failed to resolve content config.'); } finally { await tempConfigServer.close(); } @@ -153,6 +156,6 @@ export async function loadContentConfig({ if (config.success) { return config.data; } else { - return new TypeError('Content config file is invalid.'); + return new ZodParseError('Content config file is invalid.'); } }