Skip to content

Commit 870ae07

Browse files
committed
Lets favor not throwing in the FirstMatchStrategy also
Signed-off-by: penguindan <[email protected]>
1 parent 6fe18eb commit 870ae07

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

kotlin-sdk/src/commonMain/kotlin/dev/openfeature/kotlin/sdk/multiprovider/FirstMatchStrategy.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,17 @@ class FirstMatchStrategy : MultiProvider.Strategy {
3535
if (eval.errorCode != ErrorCode.FLAG_NOT_FOUND) {
3636
return eval
3737
}
38-
// Continue to next provider if error is FLAG_NOT_FOUND
3938
} catch (_: OpenFeatureError.FlagNotFoundError) {
4039
// Handle FLAG_NOT_FOUND exception - continue to next provider
4140
continue
41+
} catch (error: OpenFeatureError) {
42+
return ProviderEvaluation(
43+
defaultValue,
44+
reason = Reason.ERROR.toString(),
45+
errorCode = error.errorCode(),
46+
errorMessage = error.message,
47+
)
4248
}
43-
// We don't catch any other exception, but rather, bubble up the exceptions
4449
}
4550

4651
// No provider knew about the flag, return default value with DEFAULT reason

0 commit comments

Comments
 (0)