From 2c60dbd4fb94a89e1c0ea7acf5c70634871441e5 Mon Sep 17 00:00:00 2001 From: Anthony Woods Date: Tue, 29 Mar 2016 15:35:08 +0800 Subject: [PATCH] handle errors when requesting plugin list. fixes #4494 --- pkg/cmd/grafana-cli/services/services.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/cmd/grafana-cli/services/services.go b/pkg/cmd/grafana-cli/services/services.go index 57a037a1d16..f7a8379cd35 100644 --- a/pkg/cmd/grafana-cli/services/services.go +++ b/pkg/cmd/grafana-cli/services/services.go @@ -15,14 +15,16 @@ var IoHelper m.IoUtil = IoUtilImp{} func ListAllPlugins(repoUrl string) (m.PluginRepo, error) { fullUrl := repoUrl + "/repo" - res, _ := goreq.Request{Uri: fullUrl, MaxRedirects: 3}.Do() - + res, err := goreq.Request{Uri: fullUrl, MaxRedirects: 3}.Do() + if err != nil { + return m.PluginRepo{}, err + } if res.StatusCode != 200 { return m.PluginRepo{}, fmt.Errorf("Could not access %s statuscode %v", fullUrl, res.StatusCode) } var resp m.PluginRepo - err := res.Body.FromJsonTo(&resp) + err = res.Body.FromJsonTo(&resp) if err != nil { return m.PluginRepo{}, errors.New("Could not load plugin data") }