diff --git a/src/OpenFeature/Providers/Memory/InMemoryProvider.cs b/src/OpenFeature/Providers/Memory/InMemoryProvider.cs index f95a0a06a..2eec879d0 100644 --- a/src/OpenFeature/Providers/Memory/InMemoryProvider.cs +++ b/src/OpenFeature/Providers/Memory/InMemoryProvider.cs @@ -3,7 +3,6 @@ using System.Threading; using System.Threading.Tasks; using OpenFeature.Constant; -using OpenFeature.Error; using OpenFeature.Model; namespace OpenFeature.Providers.Memory @@ -112,7 +111,7 @@ private ResolutionDetails Resolve(string flagKey, T defaultValue, Evaluati return value.Evaluate(flagKey, defaultValue, context); } - throw new TypeMismatchException($"flag {flagKey} is not of type {typeof(T)}"); + return new ResolutionDetails(flagKey, defaultValue, ErrorType.TypeMismatch, Reason.Error); } } } diff --git a/test/OpenFeature.Tests/Providers/Memory/InMemoryProviderTests.cs b/test/OpenFeature.Tests/Providers/Memory/InMemoryProviderTests.cs index 7a174fc51..c575dc56c 100644 --- a/test/OpenFeature.Tests/Providers/Memory/InMemoryProviderTests.cs +++ b/test/OpenFeature.Tests/Providers/Memory/InMemoryProviderTests.cs @@ -186,9 +186,14 @@ public async Task MissingFlag_ShouldReturnFlagNotFoundEvaluationFlag() } [Fact] - public async Task MismatchedFlag_ShouldThrow() + public async Task MismatchedFlag_ShouldReturnTypeMismatchError() { - await Assert.ThrowsAsync(() => this.commonProvider.ResolveStringValueAsync("boolean-flag", "nope", EvaluationContext.Empty)); + // Act + var result = await this.commonProvider.ResolveStringValueAsync("boolean-flag", "nope", EvaluationContext.Empty); + + // Assert + Assert.Equal(Reason.Error, result.Reason); + Assert.Equal(ErrorType.TypeMismatch, result.ErrorType); } [Fact]