Common System 0.2.0
Common interfaces and patterns for system integration
Loading...
Searching...
No Matches
kcenon::common::error_info Struct Referenceexport

Standard error information used by Result<T>. More...

#include <core.h>

Collaboration diagram for kcenon::common::error_info:
Collaboration graph

Public Member Functions

 error_info ()
 
 error_info (const std::string &msg)
 Construct with message only.
 
 error_info (int c, const std::string &msg, const std::string &mod="")
 Construct with code, message and optional module.
 
 error_info (int c, const std::string &msg, const std::string &mod, const std::string &det)
 Construct with code, message, module and details.
 
template<typename Enum , typename std::enable_if_t< std::is_enum_v< Enum >, int > = 0>
 error_info (Enum c, std::string msg, std::string mod="", std::optional< std::string > det=std::nullopt)
 Construct from strongly-typed enum error codes.
 
bool operator== (const error_info &other) const
 
bool operator!= (const error_info &other) const
 
 error_info (const typed_error_code &ec)
 Construct from the new category-based typed_error_code type.
 
 error_info ()
 
 error_info (const std::string &msg)
 Construct with message only.
 
 error_info (int c, const std::string &msg, const std::string &mod="")
 Construct with code, message and optional module.
 
 error_info (int c, const std::string &msg, const std::string &mod, const std::string &det)
 Construct with code, message, module and details.
 
template<typename Enum , typename std::enable_if_t< std::is_enum_v< Enum >, int > = 0>
 error_info (Enum c, std::string msg, std::string mod="", std::optional< std::string > det=std::nullopt)
 Construct from strongly-typed enum error codes.
 
bool operator== (const error_info &other) const
 
bool operator!= (const error_info &other) const
 

Public Attributes

int code
 
std::string message
 
std::string module
 
std::optional< std::string > details
 

Detailed Description

Standard error information used by Result<T>.

Examples
executor_example.cpp, and result_example.cpp.

Definition at line 106 of file core.cppm.

Constructor & Destructor Documentation

◆ error_info() [1/11]

kcenon::common::error_info::error_info ( )
inline

Definition at line 86 of file core.h.

86: code(0) {}

◆ error_info() [2/11]

kcenon::common::error_info::error_info ( const std::string & msg)
inline

Construct with message only.

Definition at line 89 of file core.h.

90 : code(-1), message(msg), module("") {}
std::string message
Definition core.h:82
std::string module
Definition core.h:83

◆ error_info() [3/11]

kcenon::common::error_info::error_info ( int c,
const std::string & msg,
const std::string & mod = "" )
inline

Construct with code, message and optional module.

Definition at line 93 of file core.h.

94 : code(c), message(msg), module(mod) {}

◆ error_info() [4/11]

kcenon::common::error_info::error_info ( int c,
const std::string & msg,
const std::string & mod,
const std::string & det )
inline

Construct with code, message, module and details.

Definition at line 97 of file core.h.

99 : code(c), message(msg), module(mod), details(det) {}
std::optional< std::string > details
Definition core.h:84

◆ error_info() [5/11]

template<typename Enum , typename std::enable_if_t< std::is_enum_v< Enum >, int > = 0>
kcenon::common::error_info::error_info ( Enum c,
std::string msg,
std::string mod = "",
std::optional< std::string > det = std::nullopt )
inline

Construct from strongly-typed enum error codes.

Enables database_system/network_system enums to be passed directly without manual static_cast noise.

Definition at line 109 of file core.h.

111 : code(static_cast<int>(c)),
112 message(std::move(msg)),
113 module(std::move(mod)),
114 details(std::move(det)) {}

◆ error_info() [6/11]

kcenon::common::error_info::error_info ( const typed_error_code & ec)
inline

Construct from the new category-based typed_error_code type.

This enables seamless integration with the decentralized error category system while maintaining backward compatibility.

Parameters
ecCategory-based typed error code
See also
error_category.h for the decentralized error system

Definition at line 134 of file core.h.

135 : code(ec.value()),
136 message(ec.message()),
137 module(std::string(ec.category_name())) {}

◆ error_info() [7/11]

kcenon::common::error_info::error_info ( )
inlineexport

Definition at line 112 of file core.cppm.

112: code(0) {}

◆ error_info() [8/11]

kcenon::common::error_info::error_info ( const std::string & msg)
inlineexport

Construct with message only.

Definition at line 115 of file core.cppm.

116 : code(-1), message(msg), module("") {}

◆ error_info() [9/11]

kcenon::common::error_info::error_info ( int c,
const std::string & msg,
const std::string & mod = "" )
inlineexport

Construct with code, message and optional module.

Definition at line 119 of file core.cppm.

120 : code(c), message(msg), module(mod) {}

◆ error_info() [10/11]

kcenon::common::error_info::error_info ( int c,
const std::string & msg,
const std::string & mod,
const std::string & det )
inlineexport

Construct with code, message, module and details.

Definition at line 123 of file core.cppm.

125 : code(c), message(msg), module(mod), details(det) {}

◆ error_info() [11/11]

template<typename Enum , typename std::enable_if_t< std::is_enum_v< Enum >, int > = 0>
kcenon::common::error_info::error_info ( Enum c,
std::string msg,
std::string mod = "",
std::optional< std::string > det = std::nullopt )
inlineexport

Construct from strongly-typed enum error codes.

Definition at line 132 of file core.cppm.

134 : code(static_cast<int>(c)),
135 message(std::move(msg)),
136 module(std::move(mod)),
137 details(std::move(det)) {}

Member Function Documentation

◆ operator!=() [1/2]

bool kcenon::common::error_info::operator!= ( const error_info & other) const
inline

Definition at line 121 of file core.h.

121 {
122 return !(*this == other);
123 }

◆ operator!=() [2/2]

bool kcenon::common::error_info::operator!= ( const error_info & other) const
inlineexport

Definition at line 144 of file core.cppm.

144 {
145 return !(*this == other);
146 }

◆ operator==() [1/2]

bool kcenon::common::error_info::operator== ( const error_info & other) const
inline

Definition at line 116 of file core.h.

116 {
117 return code == other.code && message == other.message &&
118 module == other.module && details == other.details;
119 }

References code, and message.

◆ operator==() [2/2]

bool kcenon::common::error_info::operator== ( const error_info & other) const
inlineexport

Definition at line 139 of file core.cppm.

139 {
140 return code == other.code && message == other.message &&
141 module == other.module && details == other.details;
142 }

References code, and message.

Member Data Documentation

◆ code

int kcenon::common::error_info::code
export

Definition at line 81 of file core.h.

Referenced by operator==().

◆ details

std::optional< std::string > kcenon::common::error_info::details
export

Definition at line 84 of file core.h.

◆ message

std::string kcenon::common::error_info::message
export

Definition at line 82 of file core.h.

Referenced by operator==().

◆ module

std::string kcenon::common::error_info::module
export

Definition at line 83 of file core.h.


The documentation for this struct was generated from the following files: