Преглед изворни кода

fix(cli): improve error handling

closes #6256
bergquist пре 9 година
родитељ
комит
2e4ca64783
1 измењених фајлова са 3 додато и 0 уклоњено
  1. 3 0
      pkg/cmd/grafana-cli/services/services.go

+ 3 - 0
pkg/cmd/grafana-cli/services/services.go

@@ -149,6 +149,9 @@ func createRequest(repoUrl string, subPaths ...string) ([]byte, error) {
 	}
 
 	res, err := HttpClient.Do(req)
+	if res.StatusCode/100 != 2 {
+		return []byte{}, fmt.Errorf("Api returned invalid status: %s", res.Status)
+	}
 
 	body, err := ioutil.ReadAll(res.Body)
 	defer res.Body.Close()