diff options
author | David Anderson <[email protected]> | 2017-01-31 15:53:35 -0800 |
---|---|---|
committer | David Anderson <[email protected]> | 2017-01-31 15:53:35 -0800 |
commit | a94dbd1d9e69346cbc08462da0b799f4d7d1d51f (patch) | |
tree | b5d5cf822fa4f35a2a342f75dee427c2a0b50cb9 | |
parent | 3cd44123fb97589bbb7aa8b0743c124a8ce81c9b (diff) |
Port extra error checking over from netboot.
-rw-r--r-- | scripts/prune_old_versions.go | 8 |
1 files changed, 8 insertions, 0 deletions
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 { |