Repository navigation
Add machine-readable Error::code() and ErrorDetail for validator errors - #120
Open
clockblocker wants to merge 3 commits into
Open
clockblocker wants to merge 3 commits into
clockblocker wants to merge 3 commits into
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #70 (
error-kind). Adds machine-readableError::code()(zero-allocation compactBuiltinErrorCodepacking for built-in validators, zerosizeof(Error)growth) andErrorDetailmetadata for custom validators and structured error reporting.BuiltinErrorCodeencoding preserves zero-allocation and zerosizeof(Error)overhead for all built-in validators (Minimum,Maximum,ExclusiveMinimum,ExclusiveMaximum,Size,CodePoints,Pattern,Email,OneOf,AllOf,AnyOf,EqualTo,NotEqualTo, etc.).wrap_error/wrap_field_errorpreserveError::code()without extra allocations.OneOf.hpp.and_then().or_else()composition andMapReader.hppexception-safe key validation preserving error codes.SourceLocationandErrorDetail::causes.Motivation
Callers using built-in (
rfl::Minimum,rfl::Pattern,rfl::Size, etc.) or custom validators currently have to parseError::what()prose to distinguish validation failure reasons for HTTP API errors, localized UI messages, or structured config diagnostics.Error::code()pairs withErrorKindandErrorDetail::pathto expose machine-readable codes without allocating on built-in validators.Verification
-Wall -Werror+REFLECTCPP_STRICT_WARNINGS=ON: 646/646 passed.APPROVE).