better error handlig of shared data

This commit is contained in:
Matt Walsh 2022-12-08 14:41:15 -06:00
parent 69d14236f1
commit d0382e0de1
3 changed files with 10 additions and 3 deletions

View file

@ -55,7 +55,9 @@ class CurrentWeather extends WeatherDisplay {
// test for data received // test for data received
if (!observations) { if (!observations) {
console.error('All current weather stations exhausted'); console.error('All current weather stations exhausted');
this.setStatus(STATUS.failed); if (this.enabled) this.setStatus(STATUS.failed);
// send failed to subscribers
this.getDataCallback(undefined);
return; return;
} }
// preload the icon // preload the icon

View file

@ -28,6 +28,10 @@ class HourlyGraph extends WeatherDisplay {
if (!super.getData()) return; if (!super.getData()) return;
const data = await getHourlyData(); const data = await getHourlyData();
if (data === undefined) {
this.setStatus(STATUS.failed);
return;
}
// get interesting data // get interesting data
const temperature = data.map((d) => d.temperature); const temperature = data.map((d) => d.temperature);

View file

@ -37,12 +37,13 @@ class Hourly extends WeatherDisplay {
} catch (e) { } catch (e) {
console.error('Get hourly forecast failed'); console.error('Get hourly forecast failed');
console.error(e.status, e.responseJSON); console.error(e.status, e.responseJSON);
this.setStatus(STATUS.failed); if (this.enabled) this.setStatus(STATUS.failed);
// return undefined to other subscribers
this.getDataCallback(undefined);
return; return;
} }
this.data = await Hourly.parseForecast(forecast.properties); this.data = await Hourly.parseForecast(forecast.properties);
this.getDataCallback(); this.getDataCallback();
if (!superResponse) return; if (!superResponse) return;