From 534ce1a5b16b07180ed343ba9e3c4272f2c85a16 Mon Sep 17 00:00:00 2001 From: Louay Alakkad Date: Wed, 1 Aug 2018 15:28:02 +0100 Subject: [PATCH] Fix handling of non-existent monitors in GetMonitor --- uptimerobot/api/monitor.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/uptimerobot/api/monitor.go b/uptimerobot/api/monitor.go index fc0b067..ce324fa 100644 --- a/uptimerobot/api/monitor.go +++ b/uptimerobot/api/monitor.go @@ -78,6 +78,11 @@ func (client UptimeRobotApiClient) GetMonitor(id int) (m Monitor, err error) { return } + if len(monitors) < 1 { + err = errors.New("Monitor not found: " + string(id)) + return + } + monitor := monitors[0].(map[string]interface{}) m.ID = id