Skip to content

Commit

Permalink
fix: Add missing error message when an error occurred (#256)
Browse files Browse the repository at this point in the history
<!-- 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 #255

---------

Signed-off-by: Thomas Poignant <thomas.poignant@gofeatureflag.org>
  • Loading branch information
thomaspoignant authored Apr 9, 2024
1 parent e654222 commit 949d53c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/OpenFeature/OpenFeatureClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ private async Task<FlagEvaluationDetails<T>> EvaluateFlag<T>(
{
this._logger.LogError(ex, "Error while evaluating flag {FlagKey}", flagKey);
var errorCode = ex is InvalidCastException ? ErrorType.TypeMismatch : ErrorType.General;
evaluation = new FlagEvaluationDetails<T>(flagKey, defaultValue, errorCode, Reason.Error, string.Empty);
evaluation = new FlagEvaluationDetails<T>(flagKey, defaultValue, errorCode, Reason.Error, string.Empty, ex.Message);
await this.TriggerErrorHooks(allHooksReversed, hookContext, ex, options).ConfigureAwait(false);
}
finally
Expand Down
1 change: 1 addition & 0 deletions test/OpenFeature.Tests/OpenFeatureClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public async Task OpenFeatureClient_Should_Return_DefaultValue_When_Type_Mismatc

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

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

Expand Down

0 comments on commit 949d53c

Please sign in to comment.