mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-30 23:08:54 +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
|
@ -26,8 +26,8 @@ function getBrowserStorage(
|
|||
}
|
||||
try {
|
||||
return window[storageType];
|
||||
} catch (e) {
|
||||
logOnceBrowserStorageNotAvailableWarning(e as Error);
|
||||
} catch (err) {
|
||||
logOnceBrowserStorageNotAvailableWarning(err as Error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -98,23 +98,26 @@ export const createStorageSlot = (
|
|||
get: () => {
|
||||
try {
|
||||
return browserStorage.getItem(key);
|
||||
} catch (e) {
|
||||
console.error(`Docusaurus storage error, can't get key=${key}`, e);
|
||||
} catch (err) {
|
||||
console.error(`Docusaurus storage error, can't get key=${key}`, err);
|
||||
return null;
|
||||
}
|
||||
},
|
||||
set: (value) => {
|
||||
try {
|
||||
browserStorage.setItem(key, value);
|
||||
} catch (e) {
|
||||
console.error(`Docusaurus storage error, can't set ${key}=${value}`, e);
|
||||
} catch (err) {
|
||||
console.error(
|
||||
`Docusaurus storage error, can't set ${key}=${value}`,
|
||||
err,
|
||||
);
|
||||
}
|
||||
},
|
||||
del: () => {
|
||||
try {
|
||||
browserStorage.removeItem(key);
|
||||
} catch (e) {
|
||||
console.error(`Docusaurus storage error, can't delete key=${key}`, e);
|
||||
} catch (err) {
|
||||
console.error(`Docusaurus storage error, can't delete key=${key}`, err);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -75,7 +75,7 @@ function useLocalePluralForms(): LocalePluralForms {
|
|||
if (Intl.PluralRules) {
|
||||
try {
|
||||
return createLocalePluralForms(currentLocale);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
console.error(`Failed to use Intl.PluralRules for locale "${currentLocale}".
|
||||
Docusaurus will fallback to a default/fallback (English) Intl.PluralRules implementation.
|
||||
`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue