Skip to content

refactor(error): add typed error code enum to messaging_error_category (#220)#235

Merged
kcenon merged 1 commit into
mainfrom
refactor/issue-220-adopt-error-category-typed-codes
Feb 13, 2026
Merged

refactor(error): add typed error code enum to messaging_error_category (#220)#235
kcenon merged 1 commit into
mainfrom
refactor/issue-220-adopt-error-category-typed-codes

Conversation

@kcenon

@kcenon kcenon commented Feb 13, 2026

Copy link
Copy Markdown
Owner

Closes #220

Summary

  • Add codes enum inside messaging_error_category that mirrors all 46 constexpr int error codes from error_codes.h
  • Add make_typed_error_code(messaging_error_category::codes) overload for type-safe error code construction
  • Add 7 new unit tests covering enum values, Result integration, and backward compatibility

Context

This completes the remaining phases of Issue #220:

Design

Follows the same pattern as common_error_category::codes:

// Type-safe error code construction
auto ec = make_typed_error_code(messaging_error_category::queue_full);
return Result<int>::err(ec);

// Backward-compatible integer construction (still works)
auto ec2 = make_messaging_error_code(error::queue_full);

The codes enum uses unscoped enum codes : int (not enum class) so values are accessible directly as messaging_error_category::queue_full without the extra codes:: qualifier.

Test Plan

  • All 24 messaging error category tests pass
  • Full test suite passes (167/171, 4 pre-existing flaky failures)
  • Enum values verified identical to constexpr int constants
  • Enum-based and int-based construction produce equal typed_error_code objects
  • Result integration works with both constructor and factory method
  • Cross-category inequality verified

…y (Issue #220)

Add a `codes` enum inside `messaging_error_category` that mirrors all
constexpr int error codes from error_codes.h, following the same pattern
as common_system's `common_error_category::codes`.

This enables type-safe error code construction:
  auto ec = make_typed_error_code(messaging_error_category::queue_full);
  return Result<int>::err(ec);

Changes:
- Add `codes` enum with all 46 messaging error codes grouped by category
- Add `make_typed_error_code(messaging_error_category::codes)` overload
- Add 7 new unit tests covering enum values, Result<T> integration,
  cross-construction equivalence, and cross-category inequality
- Update header documentation with new usage examples

The existing constexpr int error codes and make_messaging_error_code()
remain unchanged for backward compatibility.
@kcenon

kcenon commented Feb 13, 2026

Copy link
Copy Markdown
Owner Author

CI/CD Failure Analysis

Analysis Time: 2026-02-14 UTC
Attempt: #1

Failed Workflows

Workflow Job Step Status
CI windows-2022 / msvc Run tests (Windows) Failed

Root Cause Analysis

Primary Error:

test_standalone_backend.cpp(163): error: Expected: (executor->worker_count()) > (0), actual: 0 vs 0
[  FAILED  ] StandaloneBackendTest.ZeroThreads (13 ms)

Analysis:
This is a flaky test unrelated to PR #235 changes. The failing test StandaloneBackendTest.ZeroThreads tests thread pool worker count in test_standalone_backend.cpp, while this PR only modifies:

  • messaging_error_category.h (added codes enum)
  • test_messaging_error_category.cpp (added 7 unit tests)

The worker_count() method calls get_active_worker_count(), which returns the number of actively running workers. When no tasks are queued, active count can be 0 — a classic race condition in thread pool tests.

Evidence this is pre-existing:

Action Taken

Re-triggered the failed workflow. The flaky test should pass on retry.


Automated failure analysis - Attempt #1

@kcenon kcenon merged commit 96c4e3f into main Feb 13, 2026
15 of 16 checks passed
@kcenon kcenon deleted the refactor/issue-220-adopt-error-category-typed-codes branch February 13, 2026 15:57
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.

[Refactor] Adopt common_system error_category for typed error codes

1 participant