-
Notifications
You must be signed in to change notification settings - Fork 21
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
Conversation
Signed-off-by: Ryan Lamb <[email protected]>
Signed-off-by: Ryan Lamb <[email protected]>
Signed-off-by: Ryan Lamb <[email protected]>
Codecov Report
@@ 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
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
7a64766
to
c480ecb
Compare
@@ -1,5 +1,4 @@ | |||
using OpenFeatureSDK.Constant; |
There was a problem hiding this comment.
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.")] |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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 <[email protected]>
There was a problem hiding this 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; |
There was a problem hiding this comment.
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 🏆
public FeatureProviderException(ErrorType errorType, string message = null, Exception innerException = null) | ||
: base(message, innerException) | ||
{ |
There was a problem hiding this comment.
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 🤷
Addresses: #71
Extend the
ErrorType
to includeINVALID_CONTEXT
andTARGETING_KEY_MISSING
.Change the
ErrorType
inFlagEvaluationDetails
to an enum.Update the
FeatureProviderException
to have an enumerated code. Usemessage
for theerror message
.Update tests, and update specification references in tests.