mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-11 08:07:26 +02:00
refactor: unify error handling behavior (#6755)
* refactor: unify error handling behavior * revert * normalize paths * test... * change * does this work... * fix... * maybe fix * maybe fix * fix * fix...
This commit is contained in:
parent
dcbf9f644e
commit
f903422617
58 changed files with 1123 additions and 299 deletions
|
@ -48,10 +48,10 @@ export async function getDataFileData<T>(
|
|||
const contentString = await fs.readFile(filePath, {encoding: 'utf8'});
|
||||
const unsafeContent = Yaml.load(contentString);
|
||||
return validate(unsafeContent);
|
||||
} catch (e) {
|
||||
} catch (err) {
|
||||
// TODO replace later by error cause, see https://v8.dev/features/error-cause
|
||||
logger.error`The ${params.fileType} file at path=${filePath} looks invalid.`;
|
||||
throw e;
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ export function isValidPathname(str: string): boolean {
|
|||
// weird, but is there a better way?
|
||||
const parsedPathname = new URL(str, 'https://domain.com').pathname;
|
||||
return parsedPathname === str || parsedPathname === encodeURI(str);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,9 +193,9 @@ export function parseMarkdownString(
|
|||
contentTitle,
|
||||
excerpt,
|
||||
};
|
||||
} catch (e) {
|
||||
} catch (err) {
|
||||
logger.error(`Error while parsing Markdown front matter.
|
||||
This can happen if you use special characters in front matter values (try using double quotes around that value).`);
|
||||
throw e;
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue