Skip to content

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

Merged
kinyoklion merged 4 commits into
mainfrom
feat/error-handling-0.5.0-spec
Sep 28, 2022
Merged

feat!: ErrorType as enum, add ErrorMessage string#72
kinyoklion merged 4 commits into
mainfrom
feat/error-handling-0.5.0-spec

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Sep 27, 2022

Copy link
Copy Markdown
Member

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

codecov-commenter commented Sep 27, 2022

Copy link
Copy Markdown

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

@kinyoklion kinyoklion force-pushed the feat/error-handling-0.5.0-spec branch from 7a64766 to c480ecb Compare September 27, 2022 22:14
@@ -1,5 +1,4 @@
using OpenFeatureSDK.Constant;

Copy link
Copy Markdown
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
Copy Markdown
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.

featureProviderMock.Verify(x => x.ResolveStructureValue(flagName, defaultValue, It.IsAny<EvaluationContext>()), Times.Once);
}

[Fact]

Copy link
Copy Markdown
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

@benjiro benjiro left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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)
{

@toddbaert toddbaert Sep 28, 2022

Copy link
Copy Markdown
Member

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 🤷

Comment thread src/OpenFeatureSDK/OpenFeatureClient.cs
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.

4 participants