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 EvaluationReason use enums for Kind and ErrorKind #40

Merged
merged 4 commits into from
May 5, 2023

Conversation

cwaldren-ld
Copy link
Contributor

@cwaldren-ld cwaldren-ld commented May 5, 2023

This changes EvaluationReason's error and error_kind members to be enums instead of strings.

They are serialized to and from JSON using the tag_invoke mechanism and switch/if-else chains.

The "debug" operator<< for each enum uses boost::json::value_from under the hood. This way we could theoretically have a different debug representation, and it wouldn't affect the actual constants that are part of the JSON schema.

@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #199918: Create nice enums for flag evaluation errors.

@cwaldren-ld cwaldren-ld changed the title chore: make EvaluationReason use enums for Kind and ErrorKind feat: make EvaluationReason use enums for Kind and ErrorKind May 5, 2023
@cwaldren-ld cwaldren-ld marked this pull request as ready for review May 5, 2023 20:42
@cwaldren-ld cwaldren-ld requested a review from kinyoklion May 5, 2023 20:42
if (str == "ERROR") {
return EvaluationReason::Kind::kError;
}
return tl::make_unexpected(JsonError::kSchemaFailure);
Copy link
Member

Choose a reason for hiding this comment

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

This makes me nervous, but I guess we are locked into this contract forever already.

kinyoklion
kinyoklion approved these changes May 5, 2023
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.

2 participants