Summary
Migrate messaging_system's error codes from raw integer constants to common_system's new typed_error_code + error_category framework, enabling type-safe error handling with rich error context across the messaging infrastructure.
Parent Epic
Part of: #215 (Ecosystem Dependency Sync - Q1 2026)
Background
common_system introduced a structured error category infrastructure (commit aa542e0, #302):
include/kcenon/common/error/error_category.h (432 lines)
typed_error_code type with implicit conversion to error_info
Result<T> now accepts typed_error_code directly
- Provides compile-time error code categorization
messaging_system currently uses raw integer error codes in the range -700 to -799:
// Current: error_codes.h
namespace kcenon::messaging::error {
// Message errors (-700 to -719)
constexpr int INVALID_MESSAGE = -700;
constexpr int MESSAGE_TOO_LARGE = -701;
// ...
// Routing errors (-720 to -739)
constexpr int NO_ROUTE_FOUND = -720;
// ...
// Queue errors (-740 to -759)
constexpr int QUEUE_FULL = -740;
// ...
// Transport errors (-780 to -799)
constexpr int TRANSPORT_NOT_CONNECTED = -780;
// ...
}
Technical Specification
Current State
// Usage in messaging_system
return common::make_error<T>(
common::error_codes::INTERNAL_ERROR, // Generic common error code
"Queue is full",
"message_queue"
);
// Or with messaging-specific codes
return common::make_error<T>(
error::QUEUE_FULL, // Raw integer -740
"Message queue capacity exceeded",
"message_queue"
);
Target State
// Define messaging error category
class messaging_error_category : public common::error_category {
public:
static const messaging_error_category& instance();
std::string_view name() const noexcept override { return "messaging"; }
std::string message(int code) const override;
};
// Define typed error codes
namespace kcenon::messaging::error {
using typed_code = common::typed_error_code<messaging_error_category>;
// Message errors
inline constexpr typed_code invalid_message{-700, "Invalid message format"};
inline constexpr typed_code message_too_large{-701, "Message exceeds size limit"};
// Routing errors
inline constexpr typed_code no_route_found{-720, "No matching route for message"};
// Queue errors
inline constexpr typed_code queue_full{-740, "Message queue capacity exceeded"};
// Transport errors
inline constexpr typed_code transport_not_connected{-780, "Transport not connected"};
}
// Usage - cleaner and type-safe
return common::Result<T>{error::queue_full};
// Automatically creates error_info with code, message, and category
Implementation Tasks
Phase 1: Define Error Category
Phase 2: Convert Error Codes
Phase 3: Update Error Construction Sites
Phase 4: Backward Compatibility
Phase 5: Testing
Acceptance Criteria
Dependencies
Related Issues
Summary
Migrate messaging_system's error codes from raw integer constants to common_system's new
typed_error_code+error_categoryframework, enabling type-safe error handling with rich error context across the messaging infrastructure.Parent Epic
Part of: #215 (Ecosystem Dependency Sync - Q1 2026)
Background
common_system introduced a structured error category infrastructure (commit
aa542e0, #302):include/kcenon/common/error/error_category.h(432 lines)typed_error_codetype with implicit conversion toerror_infoResult<T>now acceptstyped_error_codedirectlymessaging_system currently uses raw integer error codes in the range -700 to -799:
Technical Specification
Current State
Target State
Implementation Tasks
Phase 1: Define Error Category
include/kcenon/messaging/error/messaging_error_category.hmessaging_error_categoryclassPhase 2: Convert Error Codes
Phase 3: Update Error Construction Sites
common::make_error<T>(code, msg, component)withResult<T>{typed_code}message_serializer.hmessage_bus.cppmessage_broker.cppPhase 4: Backward Compatibility
Phase 5: Testing
Acceptance Criteria
typed_error_codemessaging_error_categoryregistered with common_systemDependencies
Related Issues