Skip to content

feat(core): std::expected error handling - #25

Merged
XavierBeheydt merged 5 commits into
devfrom
feat/core-error
Nov 9, 2026
Merged

XavierBeheydt merged 5 commits into
devfrom
feat/core-error

Conversation

@XavierBeheydt

@XavierBeheydt XavierBeheydt commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds <aether/core/error.hpp> (header-only): EErrorCode, Error (code, message, std::source_location), Result<T> = std::expected<T, Error>, Status = Result<void> and makeError. Tests in tests/core/error.test.cpp cover success, failure, location capture, propagation, Status and monadic chaining.

Design decisions

  • Header-only: nothing needs a definition in a TU, so no export macro and no change to the library source list (fewer merge conflicts with the logger branch).
  • EErrorCode is a small enum class (Unknown, InvalidArgument, NotFound, OutOfRange, Unsupported, IoError); extend it as modules need.
  • makeError returns std::unexpected<Error> so it converts to any Result<T> and Status; its defaulted std::source_location argument records the caller's location.
  • Propagation macro: not added. AETHER_TRY would need a GNU statement expression, which is not portable to MSVC-style compilers and is not standard C++; the portable form is a statement-style macro with a hidden return, which is hard to justify for a 3-line if (!r) return std::unexpected(r.error());. std::expected monadic operations (and_then, transform) cover chaining. It can be added later if boilerplate proves heavy.

Verification

  • cmake --preset x64-debug-clang -DBUILD_TESTS=ON, build, ctest --test-dir out/build/x64-debug-clang --output-on-failure: 12/12 passed.
  • Same with x64-debug-clang-shared: 12/12 passed.
  • clang-format --dry-run --Werror on the new files: clean. clang-tidy -p out/build/x64-debug-clang tests/core/error.test.cpp (covers the header): no warnings in user code.
  • CI: see the checks on this PR.

Not verified

  • Windows clang-cl locally (left to CI).

Closes #8

🤖 Generated with Claude Code

https://claude.ai/code/session_01JfRmXnowFEecvNmG9b9szy

XavierBeheydt and others added 2 commits November 8, 2026 19:10
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JfRmXnowFEecvNmG9b9szy
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JfRmXnowFEecvNmG9b9szy
Follows the naming convention of #29 (E prefix for enums).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JfRmXnowFEecvNmG9b9szy
@XavierBeheydt
XavierBeheydt merged commit 47f9d6c into dev Nov 9, 2026
5 checks passed
@XavierBeheydt
XavierBeheydt deleted the feat/core-error branch November 9, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent: claude-code Handled by Claude Code model: sonnet Claude Sonnet (Claude Code) scope: core The core engine module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(core): std::expected error handling

1 participant