Skip to content

Commit

Permalink
Generator commit ID: 556489d with message: add error struct for 409 c…
Browse files Browse the repository at this point in the history
…onflict errors

Distinguishing conflict errors is useful for clients attempting to do
retries when an operation is rejected because of the lock being already
taken

Signed-off-by: Benny Zlotnik <[email protected]>. GitHub build: 22.
  • Loading branch information
github-actions[bot] committed Aug 8, 2023
1 parent 114c47f commit 9fd1992
Show file tree
Hide file tree
Showing 6 changed files with 19,583 additions and 23,370 deletions.
13 changes: 13 additions & 0 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ type AuthError struct {
baseError
}

// Conflict error indicates that the operation failed because of a conflict.
// For example, another operation blocks the operation from being executed.
type ConflictError struct {
baseError
}

// NotFoundError indicates that an object can't be found.
type NotFoundError struct {
baseError
Expand Down Expand Up @@ -165,6 +171,13 @@ func BuildError(response *http.Response, fault *Fault) error {
buffer.String(),
},
}
} else if response.StatusCode == 409 {
return &ConflictError{
baseError{
response.StatusCode,
buffer.String(),
},
}
}
}

Expand Down
4 changes: 1 addition & 3 deletions readers.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
//
// Copyright (c) 2017 Joey <[email protected]>.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package ovirtsdk

import (
Expand Down
Loading

0 comments on commit 9fd1992

Please sign in to comment.