Skip to content

Add rfl::Error composition methods and opt-in <rfl/error_format.hpp> - #73

Closed
clockblocker wants to merge 2 commits into
error-kindfrom
error-ergonomics-and-format
Closed

clockblocker wants to merge 2 commits into
error-kindfrom
error-ergonomics-and-format

Conversation

@clockblocker

Copy link
Copy Markdown
Owner

Summary

Stacked on #70 (error-kind, directly on main), promotes structured error composition to public rfl::Error methods and adds a standalone opt-in <rfl/error_format.hpp> header for diagnostic formatting — without changing Error::what() or pulling any extra headers into rfl.hpp.

Changes

  • include/rfl/internal/Error.hpp & include/rfl/parsing/to_single_error_message.hpp:
    • Public rfl::Error::combine(std::vector<Error>) (delegated to by rfl::parsing::to_single_error so zero duplication and 100% identical what() output).
    • Public err.in_field(std::string_view) and err.at(size_t) / err.at(ErrorDetail::PathSegment) with const& and && overloads, preserving every detail's path and kind.
  • include/rfl/error_format.hpp (standalone opt-in, never included from rfl.hpp):
    • rfl::format_path(path) — dot/bracket path formatter (users[0].address.zip, quoting special keys).
    • rfl::format_json_pointer(path) — RFC 6901 JSON Pointer (~0/~1 escaping).
    • rfl::format_error_tree(err) + custom LeafHook overload — Effect TreeFormatter-style grouped multi-line diagnostic tree (automatically renders (line L, col C) when #42b SourceLocation is present).
  • tests/json/test_error_format.cpp:
    • Tests Error::combine, lvalue/rvalue .in_field()/.at(), format_path, format_json_pointer, format_error_tree (default + LeafHook switching on ErrorKind), and rfl::json::write(err.details()) round-trip JSON serialization.

Verification

  • Standalone header check (-std=c++20 -Wall -Wextra -Werror) on <rfl/error_format.hpp> passed.
  • Built with Ninja (-O3 -Wall -Werror) and ran all error test suites cleanly.

@clockblocker

Copy link
Copy Markdown
Owner Author

Branch is preserved on fork and showcase/all-lanes (d0f1fca1) as a reference artifact and parked in #117 (Moonshots & Possible Scope Creep).

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