Skip to content

Commit

Permalink
fix: ssh error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
d-strobel committed Oct 15, 2023
1 parent 359657e commit c40c785
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions connection/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,16 @@ func (c *Connection) runSSH(ctx context.Context, cmd string) (string, string, er

// Wait for the command to complete
err = s.Wait()
if err != nil {

// Return the error if stderr has no value
if err != nil && stderrBytes == nil {
return "", "", err
}

return string(stdoutBytes), string(stderrBytes), nil
// Return stderr over the error when stderr has a value
if stderrBytes != nil {
return "", string(stderrBytes), nil
}

return string(stdoutBytes), "", nil
}

0 comments on commit c40c785

Please sign in to comment.