Skip to content

Commit 1f8e3eb

Browse files
committed
Use errdefs.IsNotFound for error checking in stop command
1 parent 0408af1 commit 1f8e3eb

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

internal/container/stop.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package container
33
import (
44
"context"
55
"fmt"
6-
"strings"
76

7+
"github.com/docker/docker/errdefs"
88
"github.com/localstack/lstk/internal/config"
99
"github.com/localstack/lstk/internal/runtime"
1010
)
@@ -33,11 +33,8 @@ type StopError struct {
3333
}
3434

3535
func (e *StopError) Error() string {
36-
msg := e.Err.Error()
37-
38-
if strings.Contains(msg, "No such container") || strings.Contains(msg, "not found") {
36+
if errdefs.IsNotFound(e.Err) {
3937
return fmt.Sprintf("%s is not running", e.Name)
4038
}
41-
42-
return fmt.Sprintf("Failed to stop %s\n%s", e.Name, msg)
39+
return fmt.Sprintf("Failed to stop %s\n%s", e.Name, e.Err.Error())
4340
}

0 commit comments

Comments
 (0)