Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
DEMO
Loading...
Searching...
No Matches
signet::forge::Error Struct Reference

Lightweight error value carrying an ErrorCode and a human-readable message. More...

#include <error.hpp>

Public Member Functions

 Error ()
 Construct a default (OK) error with no message.
 
 Error (ErrorCode c, std::string msg)
 Construct an error with the given code and descriptive message.
 
bool ok () const
 Return true if this error represents success (code == OK).
 
 operator bool () const
 Return true if this error represents a failure (code != OK).
 

Public Attributes

ErrorCode code
 The machine-readable error category.
 
std::string message
 A human-readable description of what went wrong (may be empty for OK).
 

Detailed Description

Lightweight error value carrying an ErrorCode and a human-readable message.

An Error with code == ErrorCode::OK represents "no error". The ok() helper and operator bool() let callers test for failure idiomatically:

Error e = some_operation();
if (e) { /* has error */ }
if (e.ok()) { /* no error */ }
Lightweight error value carrying an ErrorCode and a human-readable message.
Definition error.hpp:101
bool ok() const
Return true if this error represents success (code == OK).
Definition error.hpp:115
Note
operator bool() returns true when the Error is an error (i.e. !ok()), following the convention "truthy means failure".

Definition at line 101 of file error.hpp.

Constructor & Destructor Documentation

◆ Error() [1/2]

signet::forge::Error::Error ( )
inline

Construct a default (OK) error with no message.

Definition at line 108 of file error.hpp.

◆ Error() [2/2]

signet::forge::Error::Error ( ErrorCode  c,
std::string  msg 
)
inline

Construct an error with the given code and descriptive message.

Parameters
cThe error code.
msgA human-readable error description (moved into the struct).

Definition at line 112 of file error.hpp.

Member Function Documentation

◆ ok()

bool signet::forge::Error::ok ( ) const
inline

Return true if this error represents success (code == OK).

Definition at line 115 of file error.hpp.

◆ operator bool()

signet::forge::Error::operator bool ( ) const
inlineexplicit

Return true if this error represents a failure (code != OK).

Note
Explicit to prevent accidental implicit conversions.

Definition at line 118 of file error.hpp.

Member Data Documentation

◆ code

ErrorCode signet::forge::Error::code

The machine-readable error category.

Definition at line 103 of file error.hpp.

◆ message

std::string signet::forge::Error::message

A human-readable description of what went wrong (may be empty for OK).

Definition at line 105 of file error.hpp.


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