From a94dbd1d9e69346cbc08462da0b799f4d7d1d51f Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 31 Jan 2017 15:53:35 -0800 Subject: Port extra error checking over from netboot. --- scripts/prune_old_versions.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/prune_old_versions.go b/scripts/prune_old_versions.go index dfdd16c..42e031e 100644 --- a/scripts/prune_old_versions.go +++ b/scripts/prune_old_versions.go @@ -18,6 +18,7 @@ import ( "encoding/json" "flag" "fmt" + "io/ioutil" "net/http" "os" "sort" @@ -105,6 +106,13 @@ func packageVersions(user, repo, typ, distro, version, pkgname, arch string) ([] return nil, fmt.Errorf("get versions.json: %s", err) } defer resp.Body.Close() + if resp.StatusCode != 200 { + msg, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, fmt.Errorf("get error message of versions.json get: %s", err) + } + return nil, fmt.Errorf("get versions.json: %s (%q)", resp.Status, string(msg)) + } var files []packageMeta if err := json.NewDecoder(resp.Body).Decode(&files); err != nil { -- cgit v1.2.3