fix: handle error and console.log

This commit is contained in:
Maël Gangloff 2024-08-27 20:02:38 +02:00
parent 46ac93df89
commit 0d8c57265e
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
2 changed files with 5 additions and 5 deletions

View File

@ -5,10 +5,10 @@ export const regionNames = new Intl.DisplayNames([locale], {type: 'region'})
if (locale !== 'en') {
fetch(`/locales/${locale}.po.json`).then(response => {
if (!response.ok) throw new Error(`Failed to load translations for locale ${locale}`);
if (!response.ok) throw new Error(`Failed to load translations for locale ${locale}`)
response.json().then(translationsObj => {
addLocale(locale, translationsObj);
useLocale(locale);
addLocale(locale, translationsObj)
useLocale(locale)
})
})
}).catch(() => console.error(`Unable to retrieve translation file ${locale}.po.json`))
}

View File

@ -13,7 +13,7 @@ export default function TextPage({resource}: { resource: string }) {
axios.get('/content/' + resource)
.then(res => setMarkdown(res.data))
.catch(err => {
console.error(err)
console.error(`Please create the /public/content/${resource} file.`)
setMarkdown(undefined)
})
.finally(() => setLoading(false))