CnxError struct

CnxError provides an extensible, configurable type for communicating recoverable errors via error codes and error message strings

Example

CnxError do_thing(i64 input, i64* restrict out) {
    // do things ...
    if(errno) {
        return cnx_error_new(errno, CNX_POSIX_ERROR_CATEGORY);
    }
    else {
        *out = 42;
        return cnx_error_new(0, CNX_POSIX_ERROR_CATEGORY);
    }
}

void func(void) {
    i64 i = 0;
    let maybe_err = do_thing(10, &i);
    if(cnx_error_code(&maybe_err) != 0) {
        // handle error ...
    }
    // do other things...
}

In most cases, CnxError would be used in tandem with CnxResult(T) to enable concise error handling without having to use "out" parameters.

Public variables

i64 m_error_code
The error code associated with this error.
CnxErrorCategory m_error_category
The error category to convert the error code to a textual message.