fix: handle invalid weather API key gracefully and fix TideDisplay crash

- Fix TideDisplay component crash (use extremes instead of tides)
- Handle 401 weather API errors gracefully (return null data with note)
- Update weather controller to return 200 with null values instead of 503
- Add helpful message about API key activation time
- Fix tide type capitalization (High/Low instead of high/low)
This commit is contained in:
2025-11-16 23:27:10 +00:00
parent 3d487a468e
commit 311d3aa60b
4 changed files with 20 additions and 11 deletions

View File

@@ -150,8 +150,13 @@ export const getWeatherData = async (
cache.set(cacheKey, weatherData, CACHE_EXPIRATION);
return weatherData;
} catch (error) {
console.error('Error fetching weather data:', error);
} catch (error: any) {
// Handle specific error cases
if (error.response?.status === 401) {
console.warn('OpenWeatherMap API key is invalid or not activated yet. Keys can take a few hours to activate.');
} else {
console.error('Error fetching weather data:', error.message);
}
return null;
}
};