diff --git a/runner/cmd.go b/runner/cmd.go index dcf933cad0a61d8fa450395a504f7223003f26fa_cnVubmVyL2NtZC5nbw==..659de86e0598b60c975a9ea2c29bb813a7e9b076_cnVubmVyL2NtZC5nbw== 100644 --- a/runner/cmd.go +++ b/runner/cmd.go @@ -1,9 +1,11 @@ package runner import ( + "fmt" + "github.com/go-cmd/cmd" ) func RunCMD(c *cmd.Cmd) (err error, stdout, stderr []string) { statusChan := c.Start() status := <-statusChan @@ -4,11 +6,11 @@ "github.com/go-cmd/cmd" ) func RunCMD(c *cmd.Cmd) (err error, stdout, stderr []string) { statusChan := c.Start() status := <-statusChan - if status.Error != nil { - return err, status.Stdout, status.Stderr + if status.Error != nil || status.Exit > 0 { + return fmt.Errorf("Cannot execute command: %w", err), status.Stdout, status.Stderr } stdout = status.Stdout stderr = status.Stderr diff --git a/runner/main.go b/runner/main.go index dcf933cad0a61d8fa450395a504f7223003f26fa_cnVubmVyL21haW4uZ28=..659de86e0598b60c975a9ea2c29bb813a7e9b076_cnVubmVyL21haW4uZ28= 100644 --- a/runner/main.go +++ b/runner/main.go @@ -67,6 +67,9 @@ Str("stderr", strings.Join(stdErr, "\n")). Msg("failed to run command") + // TODO: print error to stderr + // Error must be pretty printed to end users /!\ + fmt.Printf("\n%s\n\n", strings.Join(stdErr, "\n")) return fmt.Errorf("failed to run command: %w", err) } if tmpFile, err := ioutil.TempFile(tmpDir, fmt.Sprintf("compiled-%s-", name)); err != nil { @@ -101,6 +104,9 @@ Str("stderr", strings.Join(stdErr, "\n")). Msg("failed to run command") + // TODO: print error to stderr + // Error message must be pretty printed to end users + fmt.Printf("\n%s\n\n", strings.Join(stdErr, "\n")) return fmt.Errorf("failed to run command: %w", err) } if tmpFile, err := ioutil.TempFile(tmpDir, "fully-compiled-"); err != nil {