fix panic when vagrant cloud response fails

This commit is contained in:
Chris Farmiloe 2014-08-12 18:11:27 +02:00
parent a5bc5beccb
commit 51f55dda48
1 changed files with 6 additions and 1 deletions

View File

@ -33,7 +33,12 @@ func (s *stepVerifyBox) Run(state multistep.StateBag) multistep.StepAction {
path := fmt.Sprintf("box/%s", config.Tag)
resp, err := client.Get(path)
if err != nil || (resp.StatusCode != 200) {
if err != nil {
state.Put("error", fmt.Errorf("Error retrieving box: %s", err))
return multistep.ActionHalt
}
if resp.StatusCode != 200 {
cloudErrors := &VagrantCloudErrors{}
err = decodeBody(resp, cloudErrors)
state.Put("error", fmt.Errorf("Error retrieving box: %s", cloudErrors.FormatErrors()))