diff --git a/command/command.go b/command/command.go index b506b2c..b2d7991 100644 --- a/command/command.go +++ b/command/command.go @@ -41,7 +41,7 @@ func (c *cmd) call(showProgress bool, msg string) (string, error) { cmd.Stderr = &stderr if err := cmd.Start(); err != nil { - return "", errors.New(string(stderr.Bytes())) + return "", errors.New(err.Error() + " " + string(stderr.Bytes())) } if showProgress { @@ -50,7 +50,7 @@ func (c *cmd) call(showProgress bool, msg string) (string, error) { } if err := cmd.Wait(); err != nil { - return "", errors.New(string(stderr.Bytes())) + return "", errors.New(err.Error() + " " + string(stderr.Bytes())) } return string(stdout.Bytes()), nil diff --git a/ip/arp.go b/ip/arp.go index 7c3f29d..7669c3b 100644 --- a/ip/arp.go +++ b/ip/arp.go @@ -7,11 +7,14 @@ import ( "strings" ) -func getArpTable() []addr { +func getArpTable() ([]addr, error) { addrs := make([]addr, 0) - out, _ := command.Arp("-an").Call() + out, err := command.Arp("-an").Call() + if err != nil { + return nil, err + } entries := strings.Split(out, "\n") for _, entry := range entries { @@ -27,5 +30,5 @@ func getArpTable() []addr { } } - return addrs + return addrs, nil } diff --git a/ip/arp_windows.go b/ip/arp_windows.go index d3c9920..8f0a7c2 100644 --- a/ip/arp_windows.go +++ b/ip/arp_windows.go @@ -5,11 +5,14 @@ import ( "strings" ) -func getArpTable() []addr { +func getArpTable() ([]addr, error) { addrs := make([]addr, 0) - s, _ := command.Arp("-a").Call() + s, err := command.Arp("-a").Call() + if err != nil { + return nil, err + } ss := strings.Split(s, "\n\r") for _, out := range ss { @@ -25,5 +28,5 @@ func getArpTable() []addr { } } } - return addrs + return addrs, nil } diff --git a/ip/ip.go b/ip/ip.go index f7640dd..499985a 100644 --- a/ip/ip.go +++ b/ip/ip.go @@ -31,7 +31,11 @@ func Find(vmName string, purge bool) (string, error) { } for { - arp := getArpTable() + arp, err := getArpTable() + if err != nil { + return "", err + } + for i := len(arp) - 1; i >= 0; i-- { a := arp[i] if a.mac == mac {