builder/digitalocean: don't panic if error contains no message [GH-492]

This commit is contained in:
Mitchell Hashimoto 2013-10-04 10:44:04 -07:00
parent 8821ef4def
commit 4067bab3d4
2 changed files with 9 additions and 1 deletions

View File

@ -3,6 +3,8 @@
BUG FIXES: BUG FIXES:
* builder/all: timeout waiting for SSH connection is a failure. [GH-491] * builder/all: timeout waiting for SSH connection is a failure. [GH-491]
* builder/digitalocean: don't panic if erroneous API response doesn't
contain error message. [GH-492]
* builder/virtualbox: error if VirtualBox version cant be detected. [GH-488] * builder/virtualbox: error if VirtualBox version cant be detected. [GH-488]
* builder/virtualbox: detect if vboxdrv isn't properly setup. [GH-488] * builder/virtualbox: detect if vboxdrv isn't properly setup. [GH-488]

View File

@ -227,7 +227,13 @@ func NewRequest(d DigitalOceanClient, path string, params url.Values) (map[strin
} }
if status == "ERROR" { if status == "ERROR" {
status = decodedResponse["message"].(string) statusRaw, ok := decodedResponse["message"]
if ok {
status = statusRaw.(string)
} else {
status = fmt.Sprintf(
"Unknown error. Full response body: %s", body)
}
} }
lastErr = errors.New(fmt.Sprintf("Received error from DigitalOcean (%d): %s", lastErr = errors.New(fmt.Sprintf("Received error from DigitalOcean (%d): %s",