From 46d3e7c1a471f7bfdc6d4e86ae763cf01798c756 Mon Sep 17 00:00:00 2001 From: Jack Pearkes Date: Mon, 17 Jun 2013 14:31:47 +0200 Subject: [PATCH] builder/digitalocean: print bad status code as string --- builder/digitalocean/api.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/builder/digitalocean/api.go b/builder/digitalocean/api.go index 72e4752cc..e04e86d08 100644 --- a/builder/digitalocean/api.go +++ b/builder/digitalocean/api.go @@ -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 }