summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/utils/errors.go
diff options
context:
space:
mode:
authorJakub Guzik <jguzik@redhat.com>2022-01-21 23:56:23 +0100
committerJakub Guzik <jguzik@redhat.com>2022-01-22 00:31:18 +0100
commit7938f32c532557eff69ada6a29b46906c3e691a3 (patch)
tree8dd31a941623eee1e46e6911ebbdae28c91e77df /pkg/api/handlers/utils/errors.go
parentd847ad598d752dad479250b7f289858cc272cb04 (diff)
downloadpodman-7938f32c532557eff69ada6a29b46906c3e691a3.tar.gz
podman-7938f32c532557eff69ada6a29b46906c3e691a3.tar.bz2
podman-7938f32c532557eff69ada6a29b46906c3e691a3.zip
Remove unused param and clean API handlers
This commit removes error message string from utils.Error in pkg/api. Param was not used inside a function for quite a long time [NO NEW TESTS NEEDED] Signed-off-by: Jakub Guzik <jguzik@redhat.com>
Diffstat (limited to 'pkg/api/handlers/utils/errors.go')
-rw-r--r--pkg/api/handlers/utils/errors.go31
1 files changed, 11 insertions, 20 deletions
diff --git a/pkg/api/handlers/utils/errors.go b/pkg/api/handlers/utils/errors.go
index 1bce19c10..919a8df1e 100644
--- a/pkg/api/handlers/utils/errors.go
+++ b/pkg/api/handlers/utils/errors.go
@@ -1,7 +1,6 @@
package utils
import (
- "fmt"
"net/http"
"github.com/containers/podman/v4/libpod/define"
@@ -22,7 +21,7 @@ var (
//
// apiMessage and code must match the container API, and are sent to client
// err is logged on the system running the podman service
-func Error(w http.ResponseWriter, apiMessage string, code int, err error) {
+func Error(w http.ResponseWriter, code int, err error) {
// Log detailed message of what happened to machine running podman service
log.Infof("Request Failed(%s): %s", http.StatusText(code), err.Error())
em := errorhandling.ErrorModel{
@@ -37,70 +36,62 @@ func VolumeNotFound(w http.ResponseWriter, name string, err error) {
if errors.Cause(err) != define.ErrNoSuchVolume {
InternalServerError(w, err)
}
- msg := fmt.Sprintf("No such volume: %s", name)
- Error(w, msg, http.StatusNotFound, err)
+ Error(w, http.StatusNotFound, err)
}
func ContainerNotFound(w http.ResponseWriter, name string, err error) {
if errors.Cause(err) != define.ErrNoSuchCtr {
InternalServerError(w, err)
}
- msg := fmt.Sprintf("No such container: %s", name)
- Error(w, msg, http.StatusNotFound, err)
+ Error(w, http.StatusNotFound, err)
}
func ImageNotFound(w http.ResponseWriter, name string, err error) {
if errors.Cause(err) != storage.ErrImageUnknown {
InternalServerError(w, err)
}
- msg := fmt.Sprintf("No such image: %s", name)
- Error(w, msg, http.StatusNotFound, err)
+ Error(w, http.StatusNotFound, err)
}
func NetworkNotFound(w http.ResponseWriter, name string, err error) {
if errors.Cause(err) != define.ErrNoSuchNetwork {
InternalServerError(w, err)
}
- msg := fmt.Sprintf("No such network: %s", name)
- Error(w, msg, http.StatusNotFound, err)
+ Error(w, http.StatusNotFound, err)
}
func PodNotFound(w http.ResponseWriter, name string, err error) {
if errors.Cause(err) != define.ErrNoSuchPod {
InternalServerError(w, err)
}
- msg := fmt.Sprintf("No such pod: %s", name)
- Error(w, msg, http.StatusNotFound, err)
+ Error(w, http.StatusNotFound, err)
}
func SessionNotFound(w http.ResponseWriter, name string, err error) {
if errors.Cause(err) != define.ErrNoSuchExecSession {
InternalServerError(w, err)
}
- msg := fmt.Sprintf("No such exec session: %s", name)
- Error(w, msg, http.StatusNotFound, err)
+ Error(w, http.StatusNotFound, err)
}
func SecretNotFound(w http.ResponseWriter, nameOrID string, err error) {
if errors.Cause(err).Error() != "no such secret" {
InternalServerError(w, err)
}
- msg := fmt.Sprintf("No such secret: %s", nameOrID)
- Error(w, msg, http.StatusNotFound, err)
+ Error(w, http.StatusNotFound, err)
}
func ContainerNotRunning(w http.ResponseWriter, containerID string, err error) {
- msg := fmt.Sprintf("Container %s is not running", containerID)
- Error(w, msg, http.StatusConflict, err)
+ Error(w, http.StatusConflict, err)
}
func InternalServerError(w http.ResponseWriter, err error) {
- Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError, err)
+ Error(w, http.StatusInternalServerError, err)
}
func BadRequest(w http.ResponseWriter, key string, value string, err error) {
e := errors.Wrapf(err, "failed to parse query parameter '%s': %q", key, value)
- Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest, e)
+ Error(w, http.StatusBadRequest, e)
}
// UnsupportedParameter logs a given param by its string name as not supported.