Class fail_t
Defined in File fail.hpp
Class Documentation
-
class fail_t
This class represents a failure with a type and an optional message.
Public Functions
-
inline constexpr fail_t()
Default constructor.
-
inline fail_t(const uint8_t type_, const std::string &message_)
Construct from type and message
- Parameters:
type_ – Numeric failure type code.
message_ – Human-readable description of the failure.
-
inline fail_t(const fail_t &fail_, const std::string &message_)
Construct from fail type and message
- Parameters:
fail_ – Failure template whose type is reused.
message_ – Human-readable description replacing the template message.
-
inline constexpr fail_t(const uint8_t type_)
Construct from type only
- Parameters:
type_ – Numeric failure type code.
-
inline fail_t(const std::pair<uint8_t, std::string> &pair_)
Construct from {uint8_t, string} pair
- Parameters:
pair_ – Pair containing
{type_code, message}.
-
inline fail_t(const std::pair<fail_t, std::string> &pair_)
Construct from {fail_t, string} pair
- Parameters:
pair_ – Pair containing
{fail_template, message}.
-
inline fail_t &operator=(const fail_t &other_)
Copy assignment operator
- Parameters:
other_ – Failure object copied into this instance.
- Returns:
Reference to this failure object.
-
inline fail_t &operator=(uint8_t t_)
Assignment operator from uint8_t
- Parameters:
t_ – New numeric failure type code.
- Returns:
Reference to this failure object.
-
inline bool operator==(const fail_t &other_) const
Comparison operators
- Parameters:
other_ – Failure object compared against this instance.
- Returns:
truewhen both failure objects have the same type.
-
inline bool operator==(const uint8_t &t_) const
Comparison operators
- Parameters:
t_ – Numeric failure type compared against this instance.
- Returns:
truewhen this failure type equalst_.
-
inline bool operator!=(const uint8_t &type_) const
Comparison operators
- Parameters:
type_ – Numeric failure type compared against this instance.
- Returns:
truewhen this failure type differs fromtype_.
-
inline bool operator!=(const fail_t &other_) const
Comparison operator
- Parameters:
other_ – Failure object compared against this instance.
- Returns:
truewhen failure types differ.
-
inline explicit operator bool() const noexcept
Implicit conversion to bool
- Returns:
truewhen this object represents a failure.
-
inline bool operator!() const noexcept
Implicit conversion to bool
- Returns:
truewhen this object represents no failure.
-
inline operator std::string() const
Implicit conversion to string for printing
- Returns:
String representation with type name and message.
-
inline bool fail() const
Check if it is a fail
- Returns:
truewhen the failure type is different fromNO_FAIL.
-
inline std::string get_message() const
Get the message
- Returns:
Failure message text associated with this error type.
-
inline void print() const
Print the fail.
Public Static Functions
-
static inline constexpr std::string_view type_name(const uint8_t t_) noexcept
Converts a failure code to its symbolic name.
- Parameters:
t_ – Numeric failure type code.
- Returns:
String view with the corresponding failure name.
Public Static Attributes
-
inline constexpr fail_t()