Skip to content

Commit

Permalink
add error struct for 409 conflict errors
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
bennyz committed Aug 7, 2023
1 parent 3547148 commit 5aa4dc3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions sdk/ovirtsdk/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 block 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

0 comments on commit 5aa4dc3

Please sign in to comment.