Improve error handling

This commit is contained in:
dump_stack() 2019-05-12 00:10:25 +00:00
parent 9ac5d98ddb
commit 660c8a5dba
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC

View File

@ -8,6 +8,7 @@
package main package main
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
@ -190,6 +191,13 @@ func generateVM(name string, verbose bool) (realpath, reginfo, qcow2 string, err
status := <-command.Start() status := <-command.Start()
if status.Error != nil || status.Exit != 0 { if status.Error != nil || status.Exit != 0 {
log.Println(status.Error, status.Stdout, status.Stderr) log.Println(status.Error, status.Stdout, status.Stderr)
if status.Error != nil {
err = status.Error
} else {
s := fmt.Sprintf("ret code: %d, out: %v, err: %v",
status.Exit, status.Stdout, status.Stderr)
err = errors.New(s)
}
return return
} }