Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
Loading...
Searching...
No Matches
kcenon::thread::error Class Reference

Represents an error in the thread system. More...

#include <error_handling.h>

Collaboration diagram for kcenon::thread::error:
Collaboration graph

Public Member Functions

 error (error_code code, std::string message={})
 Constructs an error with a code and optional message.
 
error_code code () const noexcept
 Gets the error code.
 
const std::string & message () const noexcept
 Gets the error message.
 
std::string to_string () const
 Converts the error to a string representation.
 
 operator std::string () const
 Implicit conversion to string.
 

Private Attributes

error_code code_
 
std::string message_
 

Detailed Description

Represents an error in the thread system.

This class encapsulates an error code and an optional message.

Definition at line 132 of file error_handling.h.

Constructor & Destructor Documentation

◆ error()

kcenon::thread::error::error ( error_code code,
std::string message = {} )
inlineexplicit

Constructs an error with a code and optional message.

Parameters
codeThe error code
messageOptional detailed message about the error

Definition at line 139 of file error_handling.h.

139 {})
140 : code_(code), message_(std::move(message)) {}
error_code code() const noexcept
Gets the error code.
const std::string & message() const noexcept
Gets the error message.
STL namespace.

Member Function Documentation

◆ code()

error_code kcenon::thread::error::code ( ) const
inlinenodiscardnoexcept

Gets the error code.

Returns
The error code

Definition at line 146 of file error_handling.h.

146{ return code_; }

References code_.

Referenced by kcenon::thread::thread_logger::log_error().

Here is the caller graph for this function:

◆ message()

const std::string & kcenon::thread::error::message ( ) const
inlinenodiscardnoexcept

Gets the error message.

Returns
The error message

Definition at line 152 of file error_handling.h.

152{ return message_; }

References message_.

Referenced by kcenon::thread::typed_thread_pool_builder< job_type >::build(), and kcenon::thread::thread_logger::log_error().

Here is the caller graph for this function:

◆ operator std::string()

kcenon::thread::error::operator std::string ( ) const
inline

Implicit conversion to string.

Definition at line 168 of file error_handling.h.

168 {
169 return to_string();
170 }
std::string to_string() const
Converts the error to a string representation.

References to_string().

Here is the call graph for this function:

◆ to_string()

std::string kcenon::thread::error::to_string ( ) const
inlinenodiscard

Converts the error to a string representation.

Returns
A string describing the error

Definition at line 158 of file error_handling.h.

158 {
159 if (message_.empty()) {
161 }
162 return error_code_to_string(code_) + ": " + message_;
163 }
std::string error_code_to_string(error_code code)
Converts an error_code to a string representation.

References code_, kcenon::thread::error_code_to_string(), and message_.

Referenced by operator std::string(), kcenon::thread::result_to_optional_error(), kcenon::thread::result_to_pair(), kcenon::thread::result< T >::value_or_throw(), kcenon::thread::result< T >::value_or_throw(), and kcenon::thread::result< void >::value_or_throw().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ code_

error_code kcenon::thread::error::code_
private

Definition at line 173 of file error_handling.h.

Referenced by code(), and to_string().

◆ message_

std::string kcenon::thread::error::message_
private

Definition at line 174 of file error_handling.h.

Referenced by message(), and to_string().


The documentation for this class was generated from the following file: