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:
Sébastien Lorber 2021-06-16 20:16:55 +02:00 committed by GitHub
parent b54ec72389
commit 1b0acc5547
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 178 additions and 116 deletions

View file

@ -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;
}
}