check for nil body from upload response

This commit is contained in:
Matthew Hooker 2017-11-02 00:13:31 -07:00
parent 7810dd18cd
commit 52558e4f75
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
1 changed files with 7 additions and 3 deletions

View File

@ -30,9 +30,13 @@ func (s *stepPrepareUpload) Run(state multistep.StateBag) multistep.StepAction {
resp, err := client.Get(path)
if err != nil || (resp.StatusCode != 200) {
cloudErrors := &VagrantCloudErrors{}
err = decodeBody(resp, cloudErrors)
state.Put("error", fmt.Errorf("Error preparing upload: %s", cloudErrors.FormatErrors()))
if resp == nil || resp.Body == nil {
state.Put("error", "No response from server.")
} else {
cloudErrors := &VagrantCloudErrors{}
err = decodeBody(resp, cloudErrors)
state.Put("error", fmt.Errorf("Error preparing upload: %s", cloudErrors.FormatErrors()))
}
return multistep.ActionHalt
}