Skip to content

Commit

Permalink
Updated FeatureFlagResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
yakovmanshin committed May 11, 2024
1 parent 3c3cd52 commit 5f24019
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions Sources/YMFF/FeatureFlagResolver/FeatureFlagResolver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,16 @@ extension FeatureFlagResolver {
}

for store in matchingStores {
if await store.containsValue(forKey: key) {
do {
let value: Value = try await store.value(forKey: key)
return value
} catch {
switch await store.value(forKey: key) as Result<Value, _> {
case .success(let value):
return value
case .failure(let error):
switch error {
case .valueNotFound:
continue
case .typeMismatch:
throw Error.storeError(error)
case .otherError(let error):
throw Error.storeError(error)
}
}
Expand All @@ -184,11 +189,16 @@ extension FeatureFlagResolver {
}

for store in matchingStores {
if store.containsValueSync(forKey: key) {
do {
let value: Value = try store.valueSync(forKey: key)
return value
} catch {
switch store.valueSync(forKey: key) as Result<Value, _> {
case .success(let value):
return value
case .failure(let error):
switch error {
case .valueNotFound:
continue
case .typeMismatch:
throw Error.storeError(error)
case .otherError(let error):
throw Error.storeError(error)
}
}
Expand Down

0 comments on commit 5f24019

Please sign in to comment.