feat: safeguard against invalid JSON
It appears that OpenWeatherMap sometimes sent out bad JSON. Learn from the lesson and do better in this PR. Signed-off-by: André Jaenisch <andre.jaenisch@posteo.de>
This commit is contained in:
parent
39d72e4c0d
commit
c734c05614
|
@ -322,6 +322,17 @@ local function worker(user_args)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if string.match(stdout, '<') ~= nil then
|
||||||
|
if not warning_shown then
|
||||||
|
warning_shown = true
|
||||||
|
widget:is_ok(false)
|
||||||
|
tooltip:add_to_object(widget)
|
||||||
|
|
||||||
|
widget:connect_signal('mouse::enter', function() tooltip.text = stdout end)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
warning_shown = false
|
warning_shown = false
|
||||||
tooltip:remove_from_object(widget)
|
tooltip:remove_from_object(widget)
|
||||||
widget:is_ok(true)
|
widget:is_ok(true)
|
||||||
|
|
Loading…
Reference in New Issue