Skip to content

Commit 83af976

Browse files
authored
chore: util function to handle hcloud not found errors (#880)
Will be used in #817
1 parent 17191a2 commit 83af976

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

internal/util/hcloudutil/error_framework.go

+9
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,12 @@ func APIErrorDiagnostics(err error) diag.Diagnostics {
6868
)
6969
return diagnostics
7070
}
71+
72+
// APIErrorIsNotFound check whether the error is an API request Not Found error.
73+
func APIErrorIsNotFound(err error) bool {
74+
var hcloudErr hcloud.Error
75+
if errors.As(err, &hcloudErr) {
76+
return hcloud.IsError(hcloudErr, hcloud.ErrorCodeNotFound)
77+
}
78+
return false
79+
}

0 commit comments

Comments
 (0)