diff options
author | Pavel Makhov <pavel.makhov@savoirfairelinux.com> | 2017-02-18 13:02:03 -0500 |
---|---|---|
committer | Pavel Makhov <pavel.makhov@savoirfairelinux.com> | 2017-02-18 13:02:03 -0500 |
commit | b6458cbe0ce49a87d975dc5e7dde698e16045842 (patch) | |
tree | c9ec78444fe473b0bde9938c78bab6fa95705018 /weather-widget | |
parent | 9fbcb2e54094f3d793cc46133956d30fb501830f (diff) |
fix weather widget crash with no internet connection
Diffstat (limited to 'weather-widget')
-rw-r--r-- | weather-widget/weather.lua | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/weather-widget/weather.lua b/weather-widget/weather.lua index 43158a9..41184ba 100644 --- a/weather-widget/weather.lua +++ b/weather-widget/weather.lua @@ -62,9 +62,11 @@ local resp weather_timer:connect_signal("timeout", function () local resp_json = http.request("http://api.openweathermap.org/data/2.5/weather?q=" .. city .."&appid=" .. open_map_key) - resp = json.decode(resp_json) - icon_widget.image = path_to_icons .. icon_map[resp.weather[1].icon] - temp_widget:set_text(to_celcius(resp.main.temp)) + if (resp_json ~= nil) then + resp = json.decode(resp_json) + icon_widget.image = path_to_icons .. icon_map[resp.weather[1].icon] + temp_widget:set_text(to_celcius(resp.main.temp)) + end end) weather_timer:emit_signal("timeout") |