From 3efdce8c149b8383ab2fd942a6a6e82c8466b5db Mon Sep 17 00:00:00 2001 From: Jacob Bednarz Date: Fri, 23 Dec 2022 10:00:20 +1100 Subject: [PATCH] swap string check for HTTP request error check --- tiered_cache.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tiered_cache.go b/tiered_cache.go index 39ac88d3f4..02b86b6572 100644 --- a/tiered_cache.go +++ b/tiered_cache.go @@ -22,8 +22,6 @@ type TieredCache struct { LastModified time.Time } -const notFoundError = "Unable to retrieve tiered_cache_smart_topology_enable setting value. The zone setting does not exist. (1142)" - // GetTieredCache allows you to retrieve the current Tiered Cache Settings for a Zone. // This function does not support custom topologies, only Generic and Smart Tiered Caching. // @@ -173,7 +171,8 @@ func getSmartTieredCache(api *API, ctx context.Context, rc *ResourceContainer) ( uri := fmt.Sprintf("/zones/%s/cache/tiered_cache_smart_topology_enable", rc.Identifier) res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil) if err != nil { - if err.Error() == notFoundError { + var notFoundError *NotFoundError + if errors.As(err, ¬FoundError) { return TieredCache{Type: TieredCacheOff}, nil } return TieredCache{Type: TieredCacheOff}, err @@ -283,7 +282,8 @@ func deleteSmartTieredCache(api *API, ctx context.Context, rc *ResourceContainer uri := fmt.Sprintf("/zones/%s/cache/tiered_cache_smart_topology_enable", rc.Identifier) res, err := api.makeRequestContext(ctx, http.MethodDelete, uri, nil) if err != nil { - if err.Error() == notFoundError { + var notFoundError *NotFoundError + if errors.As(err, ¬FoundError) { return TieredCache{Type: TieredCacheOff}, nil } return TieredCache{Type: TieredCacheOff}, err