1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-22 05:29:44 +02:00

show stdout in error message if stderr is blank

This commit is contained in:
Jesse Duffield 2022-03-27 14:28:30 +11:00
parent 20ec6d98ad
commit 7128d822cb

View File

@ -226,6 +226,9 @@ func (self *cmdObjRunner) runAndStreamAux(
return err
}
var stdout bytes.Buffer
handler.stdoutPipe = io.TeeReader(handler.stdoutPipe, &stdout)
defer func() {
if closeErr := handler.close(); closeErr != nil {
self.log.Error(closeErr)
@ -237,10 +240,14 @@ func (self *cmdObjRunner) runAndStreamAux(
err = cmd.Wait()
if err != nil {
errStr := stderr.String()
if cmdObj.ShouldIgnoreEmptyError() && errStr == "" {
if errStr != "" {
return errors.New(errStr)
}
if cmdObj.ShouldIgnoreEmptyError() {
return nil
}
return errors.New(stderr.String())
return errors.New(stdout.String())
}
return nil