diff options
author | zhangguanzhang <zhangguanzhang@qq.com> | 2020-08-02 21:08:13 +0800 |
---|---|---|
committer | zhangguanzhang <zhangguanzhang@qq.com> | 2020-08-02 22:21:28 +0800 |
commit | 45b100d21ce1ca1843e26366466d09eac2d4add0 (patch) | |
tree | a4fbcccc680ba028deacedb9039e8f1de07e5316 /pkg/api/handlers/compat/networks.go | |
parent | f4d4bd22887e1271c3bf04532596f4c02201022e (diff) | |
download | podman-45b100d21ce1ca1843e26366466d09eac2d4add0.tar.gz podman-45b100d21ce1ca1843e26366466d09eac2d4add0.tar.bz2 podman-45b100d21ce1ca1843e26366466d09eac2d4add0.zip |
API returns 500 in case network is not found instead of 404
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
Diffstat (limited to 'pkg/api/handlers/compat/networks.go')
-rw-r--r-- | pkg/api/handlers/compat/networks.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/pkg/api/handlers/compat/networks.go b/pkg/api/handlers/compat/networks.go index 1e80cc91d..80b7505df 100644 --- a/pkg/api/handlers/compat/networks.go +++ b/pkg/api/handlers/compat/networks.go @@ -10,6 +10,7 @@ import ( "github.com/containernetworking/cni/libcni" "github.com/containers/podman/v2/libpod" + "github.com/containers/podman/v2/libpod/define" "github.com/containers/podman/v2/pkg/api/handlers/utils" "github.com/containers/podman/v2/pkg/domain/entities" "github.com/containers/podman/v2/pkg/domain/infra/abi" @@ -44,9 +45,7 @@ func InspectNetwork(w http.ResponseWriter, r *http.Request) { name := utils.GetName(r) _, err = network.InspectNetwork(config, name) if err != nil { - // TODO our network package does not distinguish between not finding a - // specific network vs not being able to read it - utils.InternalServerError(w, err) + utils.NetworkNotFound(w, name, err) return } report, err := getNetworkResourceByName(name, runtime) @@ -285,7 +284,7 @@ func RemoveNetwork(w http.ResponseWriter, r *http.Request) { return } if !exists { - utils.Error(w, "network not found", http.StatusNotFound, network.ErrNetworkNotFound) + utils.Error(w, "network not found", http.StatusNotFound, define.ErrNoSuchNetwork) return } if err := network.RemoveNetwork(config, name); err != nil { |