sampler-fork/data/error.go

22 lines
286 B
Go
Raw Permalink Normal View History

2019-03-17 03:13:14 +00:00
package data
import (
"fmt"
"os/exec"
)
2019-03-22 03:21:00 +00:00
func getErrorMessage(err error) string {
exitErr, ok := err.(*exec.ExitError)
message := err.Error()
if ok {
stderr := string(exitErr.Stderr)
if len(stderr) != 0 {
message = fmt.Sprintf("%.200s", stderr)
}
2019-03-17 03:13:14 +00:00
}
2019-03-22 03:21:00 +00:00
return message
2019-03-17 03:13:14 +00:00
}