builder/digitalocean: print bad status code as string

This commit is contained in:
Jack Pearkes 2013-06-17 14:31:47 +02:00
parent 1e6780e496
commit 46d3e7c1a4
1 changed files with 4 additions and 6 deletions

View File

@ -154,15 +154,14 @@ func NewRequest(d DigitalOceanClient, path string, params string) (map[string]in
err = json.Unmarshal(body, &decodedResponse)
log.Printf("response from digitalocean: %v", decodedResponse)
// Catch all non-200 status and return an error
if resp.StatusCode != 200 {
err = errors.New(fmt.Sprintf("Recieved non-200 HTTP status from DigitalOcean: %d", resp.StatusCode))
log.Printf("response from digital ocean: %v", decodedResponse)
err = errors.New(fmt.Sprintf("Received non-200 HTTP status from DigitalOcean: %v", resp.StatusCode))
return decodedResponse, err
}
log.Printf("response from digital ocean: %v", decodedResponse)
if err != nil {
return decodedResponse, err
}
@ -174,8 +173,7 @@ func NewRequest(d DigitalOceanClient, path string, params string) (map[string]in
if status == "ERROR" {
status = decodedResponse["error_message"]
}
err = errors.New(fmt.Sprintf("Recieved bad status from DigitalOcean: %v", status))
log.Printf("response from digital ocean: %v", decodedResponse)
err = errors.New(fmt.Sprintf("Received bad status from DigitalOcean: %v", status))
return decodedResponse, err
}