Skip to content

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.

3 participants