Lightweight error value carrying an ErrorCode and a human-readable message.
More...
#include <error.hpp>
|
| | 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).
|
| |
|
| ErrorCode | code |
| | The machine-readable error category.
|
| |
| std::string | message |
| | A human-readable description of what went wrong (may be empty for OK).
|
| |
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) { }
Lightweight error value carrying an ErrorCode and a human-readable message.
bool ok() const
Return true if this error represents success (code == OK).
- 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.
◆ 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
-
| c | The error code. |
| msg | A human-readable error description (moved into the struct). |
Definition at line 112 of file error.hpp.
◆ 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.
◆ 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: