Class fail_t

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:

true when 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:

true when this failure type equals t_.

inline bool operator!=(const uint8_t &type_) const

Comparison operators

Parameters:

type_ – Numeric failure type compared against this instance.

Returns:

true when this failure type differs from type_.

inline bool operator!=(const fail_t &other_) const

Comparison operator

Parameters:

other_ – Failure object compared against this instance.

Returns:

true when failure types differ.

inline explicit operator bool() const noexcept

Implicit conversion to bool

Returns:

true when this object represents a failure.

inline bool operator!() const noexcept

Implicit conversion to bool

Returns:

true when 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:

true when the failure type is different from NO_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

static const fail_t NO_FAIL = {0}

No failure.

static const fail_t UNKNOWN = {1}

Unknown failure.

static const fail_t TIMEOUT = {2}

Operation timed out.

static const fail_t OUT_OF_MEMORY = {3}

Memory allocation failed.

static const fail_t INVALID_INPUT = {4}

Input arguments are invalid.

static const fail_t RUNTIME_ERROR = {5}

Runtime error occurred.

static const fail_t NOT_FOUND = {6}

Requested element was not found.

static const fail_t ALREADY_EXISTS = {7}

Element already exists.

static const fail_t IS_EMPTY = {8}

Container or resource is empty.

static const fail_t IS_FULL = {9}

Container or resource is full.

static const fail_t PERMISSION_DENIED = {10}

Operation is not permitted.

static const fail_t LOST_PTR = {11}

Referenced pointer was lost or invalid.

static const fail_t CELL_FULL = {12}

Cell reached its capacity.

static const fail_t FAIL = {13}

Generic failure state.

static const fail_t INSERTATION_FAILED = {14}

Element insertion failed.

static const fail_t OUT_OF_BOUNDS = {15}

Index or coordinate is outside valid bounds.

Private Members

uint8_t _type

Failure type.

std::string _message

Failure message.