Skip to content

Commit 949d53c

Browse files
fix: Add missing error message when an error occurred (open-feature#256)
<!-- Please use this template for your pull request. --> <!-- Please use the sections that you need and delete other sections --> ## This PR - Add missing error message when an error occurred ### Related Issues Fixes open-feature#255 --------- Signed-off-by: Thomas Poignant <[email protected]>
1 parent e654222 commit 949d53c

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
@@ -178,6 +178,7 @@ public async Task OpenFeatureClient_Should_Return_DefaultValue_When_Type_Mismatc
178178

179179
var evaluationDetails = await client.GetObjectDetails(flagName, defaultValue);
180180
evaluationDetails.ErrorType.Should().Be(ErrorType.TypeMismatch);
181+
evaluationDetails.ErrorMessage.Should().Be(new InvalidCastException().Message);
181182

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

0 commit comments

Comments
 (0)