Explorar o código

fix(cli): improve error handling

closes #6256
bergquist %!s(int64=9) %!d(string=hai) anos
pai
achega
2e4ca64783
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  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()