aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/networks/rm.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman/networks/rm.go')
-rw-r--r--cmd/podman/networks/rm.go12
1 files changed, 3 insertions, 9 deletions
diff --git a/cmd/podman/networks/rm.go b/cmd/podman/networks/rm.go
index f71f59eea..c2d3f655f 100644
--- a/cmd/podman/networks/rm.go
+++ b/cmd/podman/networks/rm.go
@@ -1,6 +1,7 @@
package network
import (
+ "errors"
"fmt"
"strings"
@@ -10,7 +11,6 @@ import (
"github.com/containers/podman/v4/cmd/podman/utils"
"github.com/containers/podman/v4/libpod/define"
"github.com/containers/podman/v4/pkg/domain/entities"
- "github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
@@ -78,15 +78,9 @@ func networkRm(cmd *cobra.Command, args []string) error {
}
func setExitCode(err error) {
- cause := errors.Cause(err)
- switch {
- case cause == define.ErrNoSuchNetwork:
+ if errors.Is(err, define.ErrNoSuchNetwork) || strings.Contains(err.Error(), define.ErrNoSuchNetwork.Error()) {
registry.SetExitCode(1)
- case strings.Contains(cause.Error(), define.ErrNoSuchNetwork.Error()):
- registry.SetExitCode(1)
- case cause == define.ErrNetworkInUse:
- registry.SetExitCode(2)
- case strings.Contains(cause.Error(), define.ErrNetworkInUse.Error()):
+ } else if errors.Is(err, define.ErrNetworkInUse) || strings.Contains(err.Error(), define.ErrNetworkInUse.Error()) {
registry.SetExitCode(2)
}
}