22#include <system_error>
25#include <kcenon/common/patterns/result.h>
94 "error_code values must be in range [-199, -100]");
97 "error_code values must be in range [-199, -100]");
105 using map_entry = std::pair<error_code, std::string_view>;
106 static constexpr map_entry kMap[] = {
134 for (
const auto& [k, v] : kMap) {
135 if (k == code)
return std::string(v);
137 return std::string(
"Unknown error code");
157 return common::error_info{
158 static_cast<int>(code),
240 [[nodiscard]]
const char*
name() const noexcept
override {
241 return "thread_system";
249 [[nodiscard]] std::string
message(
int ev)
const override {
259 [[nodiscard]]
bool equivalent(
int ev,
const std::error_condition& condition)
const noexcept override {
262 return condition == std::errc::invalid_argument;
265 return condition == std::errc::not_enough_memory;
267 return condition == std::errc::timed_out;
269 return condition == std::errc::resource_deadlock_would_occur;
315struct is_error_code_enum<
kcenon::thread::error_code> : true_type {};
std::error_category implementation for thread_system errors
const char * name() const noexcept override
Returns the name of the error category.
std::string message(int ev) const override
Returns a message for the given error code.
bool equivalent(int ev, const std::error_condition &condition) const noexcept override
Returns the equivalent std::errc for certain error codes.
Core threading foundation of the thread system library.
common::VoidResult make_error_result(error_code code, const std::string &message="")
Create a common::VoidResult error from a thread::error_code.
error_code
Strongly typed error codes for thread system operations.
@ condition_variable_error
@ circuit_half_open
Circuit breaker is in half-open state.
@ circuit_open
Circuit breaker is open, request rejected.
@ resource_allocation_failed
std::error_condition make_error_condition(error_code e) noexcept
Creates a std::error_condition from a thread_system error_code.
std::error_code make_error_code(error_code e) noexcept
Creates a std::error_code from a thread_system error_code.
error_code get_error_code(const common::error_info &info)
Extract thread::error_code from a common::error_info.
const std::error_category & thread_category() noexcept
Gets the singleton instance of thread_error_category.
common::error_info to_error_info(error_code code, const std::string &message="")
Convert a thread::error_code to common::error_info.
@ info
Informational messages highlighting progress.
std::string error_code_to_string(error_code code)
Converts an error_code to a string representation.