Skip to content

Commit f1193ef

Browse files
committed
cli/command/service: use errors.Join
Use stdlib multi-errors instead of creating our own Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent f9e4335 commit f1193ef

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

cli/command/service/remove.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ package service
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
6-
"strings"
77

88
"github.com/docker/cli/cli"
99
"github.com/docker/cli/cli/command"
10-
"github.com/pkg/errors"
1110
"github.com/spf13/cobra"
1211
)
1312

@@ -32,17 +31,13 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
3231
func runRemove(ctx context.Context, dockerCLI command.Cli, serviceIDs []string) error {
3332
apiClient := dockerCLI.Client()
3433

35-
var errs []string
34+
var errs []error
3635
for _, id := range serviceIDs {
37-
err := apiClient.ServiceRemove(ctx, id)
38-
if err != nil {
39-
errs = append(errs, err.Error())
36+
if err := apiClient.ServiceRemove(ctx, id); err != nil {
37+
errs = append(errs, err)
4038
continue
4139
}
4240
_, _ = fmt.Fprintln(dockerCLI.Out(), id)
4341
}
44-
if len(errs) > 0 {
45-
return errors.New(strings.Join(errs, "\n"))
46-
}
47-
return nil
42+
return errors.Join(errs...)
4843
}

0 commit comments

Comments
 (0)