feat: differentiate weather fetch errors by cause

This commit is contained in:
2026-06-05 19:52:33 +02:00
parent 9089e1c6f9
commit 6c83cd7d36
9 changed files with 119 additions and 17 deletions
+21 -7
View File
@@ -1178,13 +1178,27 @@ export default function LogEntryEditor({
showAlert(t('settings.weather_success'))
} catch (err) {
if (err instanceof WeatherApiError && err.code === 'OFFLINE') {
showAlert(t('logs.weather_offline'))
return
}
if (err instanceof WeatherApiError && err.code === 'NO_KEY') {
showAlert(t('settings.no_key'))
return
if (err instanceof WeatherApiError) {
if (err.code === 'OFFLINE') {
showAlert(t('logs.weather_offline'))
return
}
if (err.code === 'NO_KEY') {
showAlert(t('settings.no_key'))
return
}
if (err.code === 'UNAUTHORIZED') {
showAlert(t('settings.weather_unauthorized'))
return
}
if (err.code === 'NOT_FOUND') {
showAlert(t('settings.weather_not_found'))
return
}
if (err.code === 'BAD_REQUEST') {
showAlert(t('settings.weather_bad_request'))
return
}
}
console.error('Weather prefilling failed:', err)
showAlert(t('settings.weather_error'))