add error message to failing commands *facepalm*
This commit is contained in:
parent
0466a423ec
commit
5827a7434b
1 changed files with 12 additions and 2 deletions
14
linux/run.go
14
linux/run.go
|
@ -2,9 +2,11 @@ package linux
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"golang.org/x/sys/unix"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
|
@ -192,7 +194,11 @@ func (cmd *LinuxCommand) Run() error {
|
|||
}
|
||||
exitInfo.HasSucceeded = false
|
||||
exitInfo.ExitCode = exitErr.ExitCode()
|
||||
exitInfo.Error = exitErr.String()
|
||||
var stdoutData bytes.Buffer
|
||||
if _, err := io.Copy(&stdoutData, cmd.stdout); err != nil {
|
||||
return err
|
||||
}
|
||||
exitInfo.Error = stdoutData.String()
|
||||
err := h.(func(data EventExitData) error)(*exitInfo)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: %w", ErrRunningEvt.Error(), err)
|
||||
|
@ -206,7 +212,11 @@ func (cmd *LinuxCommand) Run() error {
|
|||
}
|
||||
exitInfo.HasSucceeded = false
|
||||
exitInfo.ExitCode = exitErr.ExitCode()
|
||||
exitInfo.Error = exitErr.String()
|
||||
var stdoutData bytes.Buffer
|
||||
if _, err := io.Copy(&stdoutData, cmd.stdout); err != nil {
|
||||
return err
|
||||
}
|
||||
exitInfo.Error = stdoutData.String()
|
||||
err := h.(func(data EventExitData) error)(*exitInfo)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: %w", ErrRunningEvt.Error(), err)
|
||||
|
|
Loading…
Reference in a new issue