mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 08:37:25 +02:00
refactor(v2): blog/docs: add more context in error messages (#4989)
* refactor(v2): blog/docs: add more context in error messages * more error handling
This commit is contained in:
parent
b54ec72389
commit
1b0acc5547
3 changed files with 178 additions and 116 deletions
|
@ -32,6 +32,7 @@ import globby from 'globby';
|
|||
import {getDocsDirPaths} from './versions';
|
||||
import {stripPathNumberPrefixes} from './numberPrefix';
|
||||
import {validateDocFrontMatter} from './docFrontMatter';
|
||||
import chalk from 'chalk';
|
||||
|
||||
type LastUpdateOptions = Pick<
|
||||
PluginOptions,
|
||||
|
@ -102,7 +103,7 @@ export async function readVersionDocs(
|
|||
);
|
||||
}
|
||||
|
||||
export function processDocMetadata({
|
||||
function doProcessDocMetadata({
|
||||
docFile,
|
||||
versionMetadata,
|
||||
context,
|
||||
|
@ -262,3 +263,21 @@ export function processDocMetadata({
|
|||
frontMatter,
|
||||
};
|
||||
}
|
||||
|
||||
export function processDocMetadata(args: {
|
||||
docFile: DocFile;
|
||||
versionMetadata: VersionMetadata;
|
||||
context: LoadContext;
|
||||
options: MetadataOptions;
|
||||
}): DocMetadataBase {
|
||||
try {
|
||||
return doProcessDocMetadata(args);
|
||||
} catch (e) {
|
||||
console.error(
|
||||
chalk.red(
|
||||
`Can't process doc metadatas for doc at path "${args.docFile.filePath}" in version "${args.versionMetadata.versionName}"`,
|
||||
),
|
||||
);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue