EtcPal
0.4.1
ETC Platform Abstraction Layer (EtcPal)
|
View other versions:
|
A wrapper class for the EtcPal error type.
Provides C++ syntactic sugar on top of etcpal_error_t codes. A Error can be created from an etcpal_error_t, and contains the code and a string representation. If the Error contains kEtcPalErrOk, it will evaluate to true in expressions (and IsOk() will return true). Otherwise, the Error evaluates to false.
The human-readable string associated with the Error can be retrieved with ToString() and ToCString(); this will be the same string available from etcpal_strerror() for the given error code.
Example with an "OK" error code:
Example with a non-"OK" error code:
Error is often used as the return type for functions; it has an implicit constructor from etcpal_error_t to simplify return statements:
Public Member Functions | |
constexpr | Error (etcpal_error_t code) noexcept |
Construct a Error from an error code. | |
Error & | operator= (etcpal_error_t code) noexcept |
Assign an error code to this Error. | |
constexpr bool | IsOk () const noexcept |
Whether this Error contains the code kEtcPalErrOk. More... | |
constexpr etcpal_error_t | code () const noexcept |
Get the underlying code from a Error. | |
std::string | ToString () const |
Get a descriptive string for this Error as a std::string. | |
const char * | ToCString () const noexcept |
Get a descriptive string for this Error as a C string. | |
constexpr | operator bool () const noexcept |
Evaluate the Error inline - evaluates true if the Error is kEtcPalErrOk, false otherwise. | |
Static Public Member Functions | |
static constexpr Error | Ok () noexcept |
Construct an Error containing kEtcPalErrOk. | |
|
constexprnoexcept |
Whether this Error contains the code kEtcPalErrOk.
kEtcPalErrOk is the only etcpal_error_t code that does not indicate an error.