|
|
|
|
@ -156,7 +156,7 @@ func NewRequest(d DigitalOceanClient, path string, params string) (map[string]in
|
|
|
|
|
|
|
|
|
|
// Catch all non-200 status and return an error
|
|
|
|
|
if resp.StatusCode != 200 {
|
|
|
|
|
err = errors.New(fmt.Sprintf("recieved non-200 status from digitalocean: %d", resp.StatusCode))
|
|
|
|
|
err = errors.New(fmt.Sprintf("Recieved non-200 HTTP status from DigitalOcean: %d", resp.StatusCode))
|
|
|
|
|
log.Printf("response from digital ocean: %v", decodedResponse)
|
|
|
|
|
return decodedResponse, err
|
|
|
|
|
}
|
|
|
|
|
@ -170,7 +170,11 @@ func NewRequest(d DigitalOceanClient, path string, params string) (map[string]in
|
|
|
|
|
// Catch all non-OK statuses from DO and return an error
|
|
|
|
|
status := decodedResponse["status"]
|
|
|
|
|
if status != "OK" {
|
|
|
|
|
err = errors.New(fmt.Sprintf("recieved non-OK status from digitalocean: %d", status))
|
|
|
|
|
// Get the actual error message if there is one
|
|
|
|
|
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)
|
|
|
|
|
return decodedResponse, err
|
|
|
|
|
}
|
|
|
|
|
|