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

feat!: ErrorType as enum, add ErrorMessage string #72

Merged
merged 4 commits into from
Sep 28, 2022

Conversation

kinyoklion
Copy link
Member

@kinyoklion kinyoklion commented Sep 27, 2022

Addresses: #71

Extend the ErrorType to include INVALID_CONTEXT and TARGETING_KEY_MISSING.
Change the ErrorType in FlagEvaluationDetails to an enum.
Update the FeatureProviderException to have an enumerated code. Use message for the error message.
Update tests, and update specification references in tests.

Signed-off-by: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com>
Signed-off-by: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com>
Signed-off-by: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com>
@codecov-commenter
Copy link

codecov-commenter commented Sep 27, 2022

Codecov Report

Merging #72 (0f63789) into main (1f7e4cb) will decrease coverage by 0.31%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #72      +/-   ##
==========================================
- Coverage   94.44%   94.13%   -0.32%     
==========================================
  Files          18       18              
  Lines         432      426       -6     
  Branches       36       36              
==========================================
- Hits          408      401       -7     
  Misses         13       13              
- Partials       11       12       +1     
Impacted Files Coverage Δ
...c/OpenFeatureSDK/Error/FeatureProviderException.cs 100.00% <100.00%> (ø)
...eatureSDK/Extension/ResolutionDetailsExtensions.cs 100.00% <100.00%> (ø)
src/OpenFeatureSDK/Model/FlagEvaluationDetails.cs 100.00% <100.00%> (ø)
src/OpenFeatureSDK/Model/ResolutionDetails.cs 100.00% <100.00%> (ø)
src/OpenFeatureSDK/OpenFeatureClient.cs 99.21% <100.00%> (ø)
src/OpenFeatureSDK/Extension/EnumExtensions.cs 80.00% <0.00%> (-20.00%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -1,5 +1,4 @@
using OpenFeatureSDK.Constant;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was renamed Evalusation -> Evaluation

[Specification("2.5", "In cases of normal execution, the `provider` SHOULD populate the `flag resolution` structure's `variant` field with a string identifier corresponding to the returned flag value.")]
[Specification("2.6", "The `provider` SHOULD populate the `flag resolution` structure's `reason` field with a string indicating the semantic reason for the returned flag value.")]
[Specification("2.7", "In cases of normal execution, the `provider` MUST NOT populate the `flag resolution` structure's `error code` field, or otherwise must populate it with a null or falsy value.")]
[Specification("2.9", "In cases of normal execution, the `provider` MUST NOT populate the `flag resolution` structure's `error code` field, or otherwise must populate it with a null or falsy value.")]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.9 was a duplicate of 2.7. I've updated it to 2.9.1 and transcribed the text. This test already demonstrated the associated specification supporting generics.

@@ -321,6 +321,36 @@ public async Task Should_Resolve_StructureValue()
featureProviderMock.Verify(x => x.ResolveStructureValue(flagName, defaultValue, It.IsAny<EvaluationContext>()), Times.Once);
}

[Fact]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added an extra test here for the case where exceptions are not being used.

Signed-off-by: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com>
@kinyoklion kinyoklion marked this pull request as ready for review September 27, 2022 22:25
Copy link
Member

@benjiro benjiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for your contribution

@@ -1,5 +1,4 @@
using OpenFeatureSDK.Constant;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on the typo 🏆

Comment on lines 23 to 25
public FeatureProviderException(ErrorType errorType, string message = null, Exception innerException = null)
: base(message, innerException)
{
Copy link
Member

@toddbaert toddbaert Sep 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Java we use dedicated exception types for each error code. I'm not saying that's better, just an option to consider.

The current implementation here might actually be easier for some providers 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants