Skip to content

Commit bd4c6cc

Browse files
fix: Add missing error message when an error occured (#258)
Backport of #256 Signed-off-by: Thomas Poignant <[email protected]> Co-authored-by: Thomas Poignant <[email protected]>
1 parent b4a2409 commit bd4c6cc

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/OpenFeature/OpenFeatureClient.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ private async Task<FlagEvaluationDetails<T>> EvaluateFlag<T>(
262262
{
263263
this._logger.LogError(ex, "Error while evaluating flag {FlagKey}", flagKey);
264264
var errorCode = ex is InvalidCastException ? ErrorType.TypeMismatch : ErrorType.General;
265-
evaluation = new FlagEvaluationDetails<T>(flagKey, defaultValue, errorCode, Reason.Error, string.Empty);
265+
evaluation = new FlagEvaluationDetails<T>(flagKey, defaultValue, errorCode, Reason.Error, string.Empty, ex.Message);
266266
await this.TriggerErrorHooks(allHooksReversed, hookContext, ex, options).ConfigureAwait(false);
267267
}
268268
finally

test/OpenFeature.Tests/OpenFeatureClientTests.cs

+1
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ public async Task OpenFeatureClient_Should_Return_DefaultValue_When_Type_Mismatc
177177

178178
var evaluationDetails = await client.GetObjectDetails(flagName, defaultValue);
179179
evaluationDetails.ErrorType.Should().Be(ErrorType.TypeMismatch);
180+
evaluationDetails.ErrorMessage.Should().Be(new InvalidCastException().Message);
180181

181182
_ = mockedFeatureProvider.Received(1).ResolveStructureValue(flagName, defaultValue, Arg.Any<EvaluationContext>());
182183

0 commit comments

Comments
 (0)