From 7ed2f9c0e18d95e6435f56b9319cf84af97519c5 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 4 Jun 2022 09:05:16 +0300 Subject: [PATCH] uptime-widget: add error handling --- main/uptimerobot-widget.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main/uptimerobot-widget.lua b/main/uptimerobot-widget.lua index c619567..e4a0f54 100644 --- a/main/uptimerobot-widget.lua +++ b/main/uptimerobot-widget.lua @@ -3,7 +3,7 @@ -- data_source = "uptimerobot.com" -- type = "widget" -- author = "Evgeny Zobnin (zobnin@gmail.com) --- version = "1.0" +-- version = "1.1" -- arguments_help = "Enter your API key" local json = require "json" @@ -34,7 +34,12 @@ function on_click() end end -function on_network_result(result) +function on_network_result(result, code) + if (code >= 400) then + ui:show_text("Error: "..code) + return + end + local parsed = json.decode(result) if (parsed.stat ~= "ok") then