Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion pkg/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ func Run(cmd *exec.Cmd) error {
return cmd.Run()
}

// StderrError is returned by RunAndLogLines when a command fails and produces
// output on stderr. Callers can use errors.As to access the raw stderr content.
type StderrError struct {
Message string
}

func (e *StderrError) Error() string {
return e.Message
}

type Executor struct {
cmd *exec.Cmd
logProxyHookJSON bool
Expand Down Expand Up @@ -147,7 +157,7 @@ func (e *Executor) RunAndLogLines(ctx context.Context, logLabels map[string]stri
err := e.cmd.Run()
if err != nil {
if len(stdErr.Bytes()) > 0 {
return nil, fmt.Errorf("stderr: %s", stdErr.String())
return nil, &StderrError{Message: stdErr.String()}
}

return nil, fmt.Errorf("cmd run: %w", err)
Expand Down
Loading