summaryrefslogtreecommitdiff
path: root/pkg/errorhandling
diff options
context:
space:
mode:
authorOndra Machacek <omachace@redhat.com>2021-10-20 18:45:56 +0200
committerMatthew Heon <matthew.heon@pm.me>2021-11-12 11:08:25 -0500
commit3bd80ac9ae2ea512a5ce9140bedab742910d0513 (patch)
tree1b1aea3de4b1443ae687ecdb5a3ada4c19a4bf58 /pkg/errorhandling
parenta8332f69460f687d704cd804673b0ccca8fd5403 (diff)
downloadpodman-3bd80ac9ae2ea512a5ce9140bedab742910d0513.tar.gz
podman-3bd80ac9ae2ea512a5ce9140bedab742910d0513.tar.bz2
podman-3bd80ac9ae2ea512a5ce9140bedab742910d0513.zip
Handle HTTP 409 error messages properly for Pod actions
This PR fixes the case when the API return HTTP 409 response. Where the API return the body format different then for other HTTP error codes. Signed-off-by: Ondra Machacek <omachace@redhat.com>
Diffstat (limited to 'pkg/errorhandling')
-rw-r--r--pkg/errorhandling/errorhandling.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/pkg/errorhandling/errorhandling.go b/pkg/errorhandling/errorhandling.go
index 6adbc9f34..fcb0f7881 100644
--- a/pkg/errorhandling/errorhandling.go
+++ b/pkg/errorhandling/errorhandling.go
@@ -83,6 +83,12 @@ func Contains(err error, sub error) bool {
return strings.Contains(err.Error(), sub.Error())
}
+// PodConflictErrorModel is used in remote connections with podman
+type PodConflictErrorModel struct {
+ Errs []string
+ Id string //nolint
+}
+
// ErrorModel is used in remote connections with podman
type ErrorModel struct {
// API root cause formatted for automated parsing
@@ -106,3 +112,11 @@ func (e ErrorModel) Cause() error {
func (e ErrorModel) Code() int {
return e.ResponseCode
}
+
+func (e PodConflictErrorModel) Error() string {
+ return strings.Join(e.Errs, ",")
+}
+
+func (e PodConflictErrorModel) Code() int {
+ return 409
+}