Skip to content
This repository was archived by the owner on Feb 27, 2018. It is now read-only.

Commit 4687cbb

Browse files
committed
Merge pull request #343 from msabramo/vmNotRunningError
Extract vmNotRunningError
2 parents 6f53b2a + 2fa8dc3 commit 4687cbb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cmds.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ import (
1818
_ "github.com/boot2docker/boot2docker-cli/virtualbox"
1919
)
2020

21+
func vmNotRunningError(vmName string) error {
22+
return fmt.Errorf("VM %q is not running. (Did you run `boot2docker up`?)", vmName)
23+
}
24+
2125
// Initialize the boot2docker VM from scratch.
2226
func cmdInit() error {
2327
B2D.Init = false
@@ -165,7 +169,7 @@ func cmdShellInit() error {
165169
}
166170

167171
if m.GetState() != driver.Running {
168-
return fmt.Errorf("VM %q is not running.", B2D.VM)
172+
return vmNotRunningError(B2D.VM)
169173
}
170174

171175
socket, err := RequestSocketFromSSH(m)
@@ -506,7 +510,7 @@ func cmdSSH() error {
506510
}
507511

508512
if m.GetState() != driver.Running {
509-
return fmt.Errorf("VM %q is not running.", B2D.VM)
513+
return vmNotRunningError(B2D.VM)
510514
}
511515

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

532536
if m.GetState() != driver.Running {
533-
return fmt.Errorf("VM %q is not running.", B2D.VM)
537+
return vmNotRunningError(B2D.VM)
534538
}
535539

536540
IP := ""

0 commit comments

Comments
 (0)