Skip to content

Commit 3553aa2

Browse files
gloursndeloof
authored andcommitted
add a default statut messsage to exec error to avoid empty line display
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
1 parent 257ea7b commit 3553aa2

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

cmd/compose/exec.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package compose
1818

1919
import (
2020
"context"
21+
"fmt"
2122

2223
"github.com/compose-spec/compose-go/v2/types"
2324
"github.com/docker/cli/cli"
@@ -109,8 +110,8 @@ func runExec(ctx context.Context, dockerCli command.Cli, backend api.Service, op
109110

110111
exitCode, err := backend.Exec(ctx, projectName, execOpts)
111112
if exitCode != 0 {
112-
errMsg := ""
113-
if err != nil {
113+
errMsg := fmt.Sprintf("exit status %d", exitCode)
114+
if err != nil && err.Error() != "" {
114115
errMsg = err.Error()
115116
}
116117
return cli.StatusError{StatusCode: exitCode, Status: errMsg}

pkg/compose/exec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (s *composeService) Exec(ctx context.Context, projectName string, options a
5252
err = container.RunExec(ctx, s.dockerCli, target.ID, exec)
5353
var sterr cli.StatusError
5454
if errors.As(err, &sterr) {
55-
return sterr.StatusCode, nil
55+
return sterr.StatusCode, err
5656
}
5757
return 0, err
5858
}

0 commit comments

Comments
 (0)