|
Rerun C++ SDK
|
Status outcome object (success or error) returned for fallible operations. More...
#include <rerun/error.hpp>
Public Member Functions | |
| Error (ErrorCode _code, std::string _description) | |
| Error (const rr_error &status) | |
| Construct from a C status object. | |
| Error (const arrow::Status &status) | |
| Construct from an arrow status. | |
| bool | operator== (const Error &other) const |
| Compare two errors for equality. Requires the description to match. | |
| bool | is_ok () const |
Returns true if the code is Ok. | |
| bool | is_err () const |
Returns true if the code is not Ok. | |
| void | handle () const |
| Handle this error based on the set log handler. | |
| void | exit_on_failure () const |
Calls the handle method and then exits the application with code 1 if the error is not Ok. | |
| void | throw_on_failure () const |
Throws a std::runtime_error if the status is not Ok. | |
Static Public Member Functions | |
| static Error | ok () |
| Creates a new error set to ok. | |
| static void | set_log_handler (StatusLogHandler handler, void *userdata=nullptr) |
Sets global log handler called for handle. | |
Public Attributes | |
| ErrorCode | code = ErrorCode::Ok |
| Result code for the given operation. | |
| std::string | description |
| Human readable description of the error. | |
Status outcome object (success or error) returned for fallible operations.
Converts to true for success, false for failure.
|
static |
Sets global log handler called for handle.
The default will log to stderr, unless RERUN_STRICT is set to something truthy.
| handler | The handler to call, or nullptr to reset to the default. |
| userdata | Userdata pointer that will be passed to each invocation of the handler. |
| void rerun::Error::handle | ( | ) | const |
Handle this error based on the set log handler.
If there is no error, nothing happens.
If you have set a log handler with set_log_handler, it will be called. Else if the RERUN_STRICT env-var is set to something truthy, an exception will be thrown (if __cpp_exceptions are enabled), or the program will abort.
If no log handler is installed, and we are not in strict mode, the error will be logged to stderr.
| void rerun::Error::exit_on_failure | ( | ) | const |
Calls the handle method and then exits the application with code 1 if the error is not Ok.
|
inline |
Throws a std::runtime_error if the status is not Ok.
If exceptions are disabled, this will forward to exit_on_failure instead.