Skip to content

Commit

Permalink
Merge pull request boot2docker#343 from msabramo/vmNotRunningError
Browse files Browse the repository at this point in the history
Extract vmNotRunningError
  • Loading branch information
gmlewis committed Feb 23, 2015
2 parents 6f53b2a + 2fa8dc3 commit 4687cbb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import (
_ "github.com/boot2docker/boot2docker-cli/virtualbox"
)

func vmNotRunningError(vmName string) error {
return fmt.Errorf("VM %q is not running. (Did you run `boot2docker up`?)", vmName)
}

// Initialize the boot2docker VM from scratch.
func cmdInit() error {
B2D.Init = false
Expand Down Expand Up @@ -165,7 +169,7 @@ func cmdShellInit() error {
}

if m.GetState() != driver.Running {
return fmt.Errorf("VM %q is not running.", B2D.VM)
return vmNotRunningError(B2D.VM)
}

socket, err := RequestSocketFromSSH(m)
Expand Down Expand Up @@ -506,7 +510,7 @@ func cmdSSH() error {
}

if m.GetState() != driver.Running {
return fmt.Errorf("VM %q is not running.", B2D.VM)
return vmNotRunningError(B2D.VM)
}

// find the ssh cmd string and then pass any remaining strings to ssh
Expand All @@ -530,7 +534,7 @@ func cmdIP() error {
}

if m.GetState() != driver.Running {
return fmt.Errorf("VM %q is not running.", B2D.VM)
return vmNotRunningError(B2D.VM)
}

IP := ""
Expand Down

0 comments on commit 4687cbb

Please sign in to comment.