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 (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
@ -192,7 +194,11 @@ func (cmd *LinuxCommand) Run() error {
|
||||||
}
|
}
|
||||||
exitInfo.HasSucceeded = false
|
exitInfo.HasSucceeded = false
|
||||||
exitInfo.ExitCode = exitErr.ExitCode()
|
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)
|
err := h.(func(data EventExitData) error)(*exitInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", ErrRunningEvt.Error(), err)
|
return fmt.Errorf("%s: %w", ErrRunningEvt.Error(), err)
|
||||||
|
@ -206,7 +212,11 @@ func (cmd *LinuxCommand) Run() error {
|
||||||
}
|
}
|
||||||
exitInfo.HasSucceeded = false
|
exitInfo.HasSucceeded = false
|
||||||
exitInfo.ExitCode = exitErr.ExitCode()
|
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)
|
err := h.(func(data EventExitData) error)(*exitInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", ErrRunningEvt.Error(), err)
|
return fmt.Errorf("%s: %w", ErrRunningEvt.Error(), err)
|
||||||
|
|
Loading…
Reference in a new issue