Skip to content

Commit

Permalink
swap string check for HTTP request error check
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobbednarz committed Dec 22, 2022
1 parent 438ff78 commit 3efdce8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tiered_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down Expand Up @@ -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, &notFoundError) {
return TieredCache{Type: TieredCacheOff}, nil
}
return TieredCache{Type: TieredCacheOff}, err
Expand Down Expand Up @@ -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, &notFoundError) {
return TieredCache{Type: TieredCacheOff}, nil
}
return TieredCache{Type: TieredCacheOff}, err
Expand Down

0 comments on commit 3efdce8

Please sign in to comment.