-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherrors.go
More file actions
30 lines (26 loc) · 912 Bytes
/
Copy patherrors.go
File metadata and controls
30 lines (26 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package stackit
import (
"errors"
"net/http"
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
)
// IsNotFound reports whether err is a STACKIT API "not found" (HTTP 404)
// error, e.g. because a resource has already been deleted out of band.
func IsNotFound(err error) bool {
var oapiErr *oapierror.GenericOpenAPIError
if errors.As(err, &oapiErr) {
return oapiErr.StatusCode == http.StatusNotFound
}
return false
}
// IsConflict reports whether err is a STACKIT API "conflict" (HTTP 409)
// error, e.g. because a resource has a dependent that has not finished
// deleting yet. Callers on the delete path should treat this as an expected,
// transient condition and requeue rather than surface it as a hard error.
func IsConflict(err error) bool {
var oapiErr *oapierror.GenericOpenAPIError
if errors.As(err, &oapiErr) {
return oapiErr.StatusCode == http.StatusConflict
}
return false
}