Skip to content

Commit

Permalink
fix: add loadContentConfig error classes back
Browse files Browse the repository at this point in the history
  • Loading branch information
bholmesdev authored and matthewp committed Dec 6, 2022
1 parent fc3e891 commit ddd4f7f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/astro/src/content/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}: {
Expand All @@ -145,14 +148,14 @@ 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();
}
const config = contentConfigParser.safeParse(unparsedConfig);
if (config.success) {
return config.data;
} else {
return new TypeError('Content config file is invalid.');
return new ZodParseError('Content config file is invalid.');
}
}

0 comments on commit ddd4f7f

Please sign in to comment.