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!: make error code an enum and include optional error message #142

Merged
merged 14 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from 7 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 specification.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
{
"id": "Requirement 2.8",
"machine_id": "requirement_2_8",
"content": "In cases of abnormal execution, the `provider` MUST indicate an error using the idioms of the implementation language, with an associated error code having possible values `\"PROVIDER_NOT_READY\"`, `\"FLAG_NOT_FOUND\"`, `\"PARSE_ERROR\"`, `\"TYPE_MISMATCH\"`, or `\"GENERAL\"`.",
"content": "In cases of abnormal execution, the `provider` MUST indicate an error using the idioms of the implementation language, with an associated error code having possible values `\"PROVIDER_NOT_READY\"`, `\"FLAG_NOT_FOUND\"`, `\"PARSE_ERROR\"`, `\"TYPE_MISMATCH\"`, `\"TARGETING_KEY_MISSING\"`, `\"INVALID_CONTEXT\"`, or `\"GENERAL\"`.",
"RFC 2119 keyword": "MUST",
"children": []
},
Expand Down
2 changes: 1 addition & 1 deletion specification/sections/01-flag-evaluation.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ FlagEvaluationDetails<MyStruct> myStructDetails = client.getObjectDetails<MyStru

> In cases of abnormal execution, the `evaluation details` structure's `error code` field **MUST** contain a string identifying an error occurred during flag evaluation and the nature of the error.

Some example error codes include: `"TARGETING_KEY_MISSING"`, `"PROVIDER_NOT_READY"`, `"FLAG_NOT_FOUND"`, `"PARSE_ERROR"`, `"TYPE_MISMATCH"`, or `"GENERAL"`.
See [error code](../types.md#error-code) for details.

##### Requirement 1.4.8

Expand Down
4 changes: 3 additions & 1 deletion specification/sections/02-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ As indicated in the definition of the [`flag resolution`](../types.md#resolution

##### Requirement 2.8

> In cases of abnormal execution, the `provider` **MUST** indicate an error using the idioms of the implementation language, with an associated error code having possible values `"PROVIDER_NOT_READY"`, `"FLAG_NOT_FOUND"`, `"PARSE_ERROR"`, `"TYPE_MISMATCH"`, or `"GENERAL"`.
> In cases of abnormal execution, the `provider` **MUST** indicate an error using the idioms of the implementation language, with an associated error code having possible values `"PROVIDER_NOT_READY"`, `"FLAG_NOT_FOUND"`, `"PARSE_ERROR"`, `"TYPE_MISMATCH"`, `"TARGETING_KEY_MISSING"`, `"INVALID_CONTEXT"`, or `"GENERAL"`.

The provider might throw an exception, return an error, or populate the `error code` object on the returned `flag resolution` structure to indicate a problem during flag value resolution.

See [error code](../types.md#error-code) for details.

##### Condition 2.9

> The implementation language supports generics (or an equivalent feature).
Expand Down
16 changes: 15 additions & 1 deletion specification/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ A structure representing the result of the [flag evaluation process](./glossary.
A structure which contains a subset of the fields defined in the `evaluation details`, representing the result of the provider's [flag resolution process](./glossary.md#resolving-flag-values), including:

- value (boolean | string | number | structure, required)
- error code (string, optional)
- error code ([error code](#error-code), optional)
- reason (string, optional)
- variant (string, optional)

Expand All @@ -62,6 +62,20 @@ A set of pre-defined reasons is enumerated below:

> NOTE: The `resolution details` structure is not exposed to the Application Author. It defines the data which Provider Authors must return when resolving the value of flags.

### Error Code

An enumerated error code represented idiomatically in the implementation language.

| Error Code | Explanation |
|-----------------------|---------------------------------------------------------------------------------------------|
| PROVIDER_NOT_READY | The value was resolved before the provider was ready. |
| FLAG_NOT_FOUND | The flag could not be found. |
| PARSE_ERROR | An error was encountered parsing data, such as a flag configuration. |
| TYPE_MISMATCH | The type of the flag value does not match the expected type. |
| TARGETING_KEY_MISSING | The provider requires a targeting key and one was not provided in the `evaluation context`. |
justinabrahms marked this conversation as resolved.
Show resolved Hide resolved
| INVALID_CONTEXT | The `evaluation context` does not meet provider requirements. |
| GENERAL | The error was for a reason not enumerated above. |

### Evaluation Options

A structure containing the following fields:
Expand Down