Skip to content

Add machine-readable Error::code() and ErrorDetail for validator errors - #120

Open
clockblocker wants to merge 3 commits into
error-kindfrom
error-detail-code
Open

clockblocker wants to merge 3 commits into
error-kindfrom
error-detail-code

Conversation

@clockblocker

@clockblocker clockblocker commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Stacked on #70 (error-kind). Adds machine-readable Error::code() (zero-allocation compact BuiltinErrorCode packing for built-in validators, zero sizeof(Error) growth) and ErrorDetail metadata for custom validators and structured error reporting.

  • Compact BuiltinErrorCode encoding preserves zero-allocation and zero sizeof(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_error preserve Error::code() without extra allocations.
  • Fixes OneOf.hpp .and_then().or_else() composition and MapReader.hpp exception-safe key validation preserving error codes.
  • Clean standalone upstream extraction: excludes fork-only YAML SourceLocation and ErrorDetail::causes.

Motivation

Callers using built-in (rfl::Minimum, rfl::Pattern, rfl::Size, etc.) or custom validators currently have to parse Error::what() prose to distinguish validation failure reasons for HTTP API errors, localized UI messages, or structured config diagnostics. Error::code() pairs with ErrorKind and ErrorDetail::path to expose machine-readable codes without allocating on built-in validators.

Verification

  • Full CTest suite under -Wall -Werror + REFLECTCPP_STRICT_WARNINGS=ON: 646/646 passed.
  • Passed Neon High Judge review (APPROVE).

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.

1 participant