fix(content-docs): give context about sidebar loading failure (#6887)

This commit is contained in:
Joshua Chen 2022-03-10 11:21:10 +08:00 committed by GitHub
parent e842b40a54
commit ff0d981853
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -98,6 +98,7 @@ export async function loadSidebars(
sidebarFilePath: string | false | undefined, sidebarFilePath: string | false | undefined,
options: SidebarProcessorParams, options: SidebarProcessorParams,
): Promise<Sidebars> { ): Promise<Sidebars> {
try {
const sidebarsConfig = await loadSidebarsFileUnsafe(sidebarFilePath); const sidebarsConfig = await loadSidebarsFileUnsafe(sidebarFilePath);
const normalizedSidebars = normalizeSidebars(sidebarsConfig); const normalizedSidebars = normalizeSidebars(sidebarsConfig);
validateSidebars(normalizedSidebars); validateSidebars(normalizedSidebars);
@ -110,4 +111,10 @@ export async function loadSidebars(
options, options,
); );
return postProcessSidebars(processedSidebars, options); return postProcessSidebars(processedSidebars, options);
} catch (err) {
logger.error`Sidebars file at path=${
sidebarFilePath as string
} failed to be loaded.`;
throw err;
}
} }