Rerun C++ SDK
Loading...
Searching...
No Matches
rerun::Error Class Reference

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.
 

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.
 

Detailed Description

Status outcome object (success or error) returned for fallible operations.

Converts to true for success, false for failure.

Member Function Documentation

◆ set_log_handler()

static void rerun::Error::set_log_handler ( StatusLogHandler  handler,
void *  userdata = nullptr 
)
static

Sets global log handler called for handle.

The default will log to stderr, unless RERUN_STRICT is set to something truthy.

Parameters
handlerThe handler to call, or nullptr to reset to the default.
userdataUserdata pointer that will be passed to each invocation of the handler.
See also
log, log_on_failure

◆ handle()

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.


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