From 9cc44a97c2041f7a5ae0459a5493542f1f57b335 Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Sat, 9 Jun 2018 04:09:04 -0700 Subject: [PATCH] Don't crash if the Weather API is missing or invalid --- weather/widget.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/weather/widget.go b/weather/widget.go index fa92b60d..8a1176cb 100644 --- a/weather/widget.go +++ b/weather/widget.go @@ -74,7 +74,9 @@ func (widget *Widget) Fetch(cityIDs []int) []*owm.CurrentWeatherData { // Refresh fetches new data from the OpenWeatherMap API and loads the new data into the. // widget's view for rendering func (widget *Widget) Refresh() { - widget.Data = widget.Fetch(wtf.ToInts(Config.UList("wtf.mods.weather.cityids", widget.defaultCityCodes()))) + if widget.apiKeyValid() { + widget.Data = widget.Fetch(wtf.ToInts(Config.UList("wtf.mods.weather.cityids", widget.defaultCityCodes()))) + } widget.UpdateRefreshedAt() widget.display()