Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add missing error message when an error occurred #256

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
toddbaert marked this conversation as resolved.
Show resolved Hide resolved
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
Loading