Add context to content-server assets download error

This commit is contained in:
chris
2020-08-05 14:47:19 -04:00
committed by Chris Marshall
parent 13d35f17f1
commit f8559befca
6 changed files with 15 additions and 12 deletions

View File

@ -14,6 +14,7 @@ import (
"strings"
httputil "github.com/criticalstack/quake-kube/internal/util/net/http"
"github.com/pkg/errors"
)
func CopyAssets(u *url.URL, dir string) error {
@ -60,7 +61,7 @@ func getManifest(url string) ([]*File, error) {
files := make([]*File, 0)
if err := json.Unmarshal(data, &files); err != nil {
return nil, err
return nil, errors.Wrapf(err, "cannot unmarshal %s/assets/manifest.json", url)
}
return files, nil
}

View File

@ -18,6 +18,10 @@ func GetBody(url string) ([]byte, error) {
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, errors.Errorf("cannot get url %q: %v", url, http.StatusText(resp.StatusCode))
}
return ioutil.ReadAll(resp.Body)
}