forked from open-feature/java-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: errorCode as enum, reason as string (open-feature#80)
* feat!: errorCode as enum, reason as string - makes errorCode an enum - makes reason a string - adds errorMessage to resolution/evaluation details Signed-off-by: Bhandari, Pramesh(AWF) <[email protected]>
- Loading branch information
Showing
18 changed files
with
98 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package dev.openfeature.javasdk; | ||
|
||
public enum ErrorCode { | ||
PROVIDER_NOT_READY, FLAG_NOT_FOUND, PARSE_ERROR, TYPE_MISMATCH, GENERAL | ||
PROVIDER_NOT_READY, FLAG_NOT_FOUND, PARSE_ERROR, TYPE_MISMATCH, TARGETING_KEY_MISSING, INVALID_CONTEXT, GENERAL | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/dev/openfeature/javasdk/exceptions/InvalidContextError.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package dev.openfeature.javasdk.exceptions; | ||
|
||
import dev.openfeature.javasdk.ErrorCode; | ||
import lombok.Getter; | ||
import lombok.experimental.StandardException; | ||
|
||
@StandardException | ||
public class InvalidContextError extends OpenFeatureError { | ||
private static final long serialVersionUID = 1L; | ||
|
||
@Getter private final ErrorCode errorCode = ErrorCode.INVALID_CONTEXT; | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/dev/openfeature/javasdk/exceptions/TargetingKeyMissingError.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package dev.openfeature.javasdk.exceptions; | ||
|
||
import dev.openfeature.javasdk.ErrorCode; | ||
import lombok.Getter; | ||
import lombok.experimental.StandardException; | ||
|
||
@StandardException | ||
public class TargetingKeyMissingError extends OpenFeatureError { | ||
private static final long serialVersionUID = 1L; | ||
|
||
@Getter private final ErrorCode errorCode = ErrorCode.TARGETING_KEY_MISSING; | ||
|
||
} |
14 changes: 8 additions & 6 deletions
14
src/test/java/dev/openfeature/javasdk/AlwaysBrokenProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,41 @@ | ||
package dev.openfeature.javasdk; | ||
|
||
import dev.openfeature.javasdk.exceptions.FlagNotFoundError; | ||
|
||
public class AlwaysBrokenProvider implements FeatureProvider { | ||
|
||
@Override | ||
public Metadata getMetadata() { | ||
return new Metadata() { | ||
@Override | ||
public String getName() { | ||
throw new NotImplementedException("BORK"); | ||
throw new FlagNotFoundError(TestConstants.BROKEN_MESSAGE); | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
public ProviderEvaluation<Boolean> getBooleanEvaluation(String key, Boolean defaultValue, EvaluationContext ctx) { | ||
throw new NotImplementedException("BORK"); | ||
throw new FlagNotFoundError(TestConstants.BROKEN_MESSAGE); | ||
} | ||
|
||
@Override | ||
public ProviderEvaluation<String> getStringEvaluation(String key, String defaultValue, EvaluationContext ctx) { | ||
throw new NotImplementedException("BORK"); | ||
throw new FlagNotFoundError(TestConstants.BROKEN_MESSAGE); | ||
} | ||
|
||
@Override | ||
public ProviderEvaluation<Integer> getIntegerEvaluation(String key, Integer defaultValue, EvaluationContext ctx) { | ||
throw new NotImplementedException("BORK"); | ||
throw new FlagNotFoundError(TestConstants.BROKEN_MESSAGE); | ||
} | ||
|
||
@Override | ||
public ProviderEvaluation<Double> getDoubleEvaluation(String key, Double defaultValue, EvaluationContext ctx) { | ||
throw new NotImplementedException("BORK"); | ||
throw new FlagNotFoundError(TestConstants.BROKEN_MESSAGE); | ||
} | ||
|
||
@Override | ||
public ProviderEvaluation<Value> getObjectEvaluation(String key, Value defaultValue, EvaluationContext invocationContext) { | ||
throw new NotImplementedException("BORK"); | ||
throw new FlagNotFoundError(TestConstants.BROKEN_MESSAGE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package dev.openfeature.javasdk; | ||
|
||
public class TestConstants { | ||
public static final String BROKEN_MESSAGE = "This is borked."; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters