From 6073fd1733519f27a6e2acc934bed99c799d0322 Mon Sep 17 00:00:00 2001 From: Matt Walsh Date: Thu, 29 May 2025 20:23:55 -0500 Subject: [PATCH] better missing data handling for current conditions #87 --- server/scripts/modules/currentweather.mjs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/scripts/modules/currentweather.mjs b/server/scripts/modules/currentweather.mjs index 0766f05..543c9c9 100644 --- a/server/scripts/modules/currentweather.mjs +++ b/server/scripts/modules/currentweather.mjs @@ -50,6 +50,8 @@ class CurrentWeather extends WeatherDisplay { stillWaiting: () => this.stillWaiting(), }); + if (observations.features.length === 0) throw new Error(`No features returned for station: ${station.properties.stationIdentifier}, trying next station`); + // test data quality if (observations.features[0].properties.temperature.value === null || observations.features[0].properties.windSpeed.value === null @@ -59,10 +61,11 @@ class CurrentWeather extends WeatherDisplay { || observations.features[0].properties.dewpoint.value === null || observations.features[0].properties.barometricPressure.value === null) { observations = undefined; - throw new Error(`Unable to get observations: ${station.properties.stationIdentifier}, trying next station`); + throw new Error(`Incomplete data set for: ${station.properties.stationIdentifier}, trying next station`); } } catch (error) { console.error(error); + observations = undefined; } } // test for data received