mirror of
https://github.com/docker/compose.git
synced 2025-07-21 12:44:54 +02:00
add a default statut messsage to exec error to avoid empty line display
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
parent
257ea7b75d
commit
3553aa26a6
@ -18,6 +18,7 @@ package compose
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/compose-spec/compose-go/v2/types"
|
||||
"github.com/docker/cli/cli"
|
||||
@ -109,8 +110,8 @@ func runExec(ctx context.Context, dockerCli command.Cli, backend api.Service, op
|
||||
|
||||
exitCode, err := backend.Exec(ctx, projectName, execOpts)
|
||||
if exitCode != 0 {
|
||||
errMsg := ""
|
||||
if err != nil {
|
||||
errMsg := fmt.Sprintf("exit status %d", exitCode)
|
||||
if err != nil && err.Error() != "" {
|
||||
errMsg = err.Error()
|
||||
}
|
||||
return cli.StatusError{StatusCode: exitCode, Status: errMsg}
|
||||
|
@ -52,7 +52,7 @@ func (s *composeService) Exec(ctx context.Context, projectName string, options a
|
||||
err = container.RunExec(ctx, s.dockerCli, target.ID, exec)
|
||||
var sterr cli.StatusError
|
||||
if errors.As(err, &sterr) {
|
||||
return sterr.StatusCode, nil
|
||||
return sterr.StatusCode, err
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user