diff --git a/util/helpers.go b/util/helpers.go index 7836f7ed0..c2d5b0aed 100644 --- a/util/helpers.go +++ b/util/helpers.go @@ -1,6 +1,8 @@ package util import ( + "errors" + "github.com/linode/linodego" ) @@ -11,9 +13,12 @@ func Pointer[T any](t T) *T { // IgnoreLinodeAPIError returns the error except matches to status code func IgnoreLinodeAPIError(err error, code int) error { - apiErr := linodego.Error{Code: code} - if apiErr.Is(err) { - err = nil + // not to be confused with linodego.APIError + var apiError *linodego.Error + if errors.As(err, &apiError) { + if apiError.StatusCode() == code { + return nil + } } return err