fix(mage): handle different types of errors

This commit is contained in:
kolaente 2022-08-03 17:11:17 +02:00
parent 51cd2830dd
commit 8f473481ac
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -79,8 +79,10 @@ func runCmdWithOutput(name string, arg ...string) (output []byte, err error) {
cmd := exec.Command(name, arg...)
output, err = cmd.Output()
if err != nil {
ee := err.(*exec.ExitError)
return nil, fmt.Errorf("error running command: %s, %s", string(ee.Stderr), err)
if ee, is := err.(*exec.ExitError); is {
return nil, fmt.Errorf("error running command: %s, %s", string(ee.Stderr), err)
}
return nil, fmt.Errorf("error running command: %s", err)
}
return output, nil