dmi_error_raise

Synopsis

#include <opendmi/error.h>

bool dmi_error_raise(dmi_context_t *context,
                     dmi_error_code_t reason);  /* macro */

Description

The dmi_error_raise macro adds an error entry with reason code reason to the error queue of context. The source file name, function name, and line number are captured automatically from the call site.

To attach a formatted message to the error, use dmi_error_raise_ex.

The error queue is a ring buffer with a maximum depth of DMI_ERROR_MAX_DEPTH entries. When the queue is full, the oldest entry is overwritten silently.

Parameters

context

DMI context.

reason

Error reason code.

Return value

Returns true on success. Returns false if context is nullptr.

Errors

None.

Examples

if (ptr == nullptr) {
    dmi_error_raise(context, DMI_ERROR_ARGUMENT_NULL);
    return false;
}