dmi_error_get_first

Synopsis

#include <opendmi/error.h>

dmi_error_t *dmi_error_get_first(dmi_context_t *context);

Description

The dmi_error_get_first function removes the oldest error descriptor from the error queue of context and returns a pointer to it. It can be called repeatedly until there are no more entries.

The returned pointer remains valid until the error queue is next modified by dmi_error_raise, dmi_error_raise_ex, dmi_error_get_first, dmi_error_get_last, or dmi_error_clear. The descriptor is no longer part of the queue, so its slot, including message, is reused by the next error raised for context, and any library function called with context may raise one. Copy whatever is needed before calling into the library again.

Parameters

context

DMI context.

Return value

Returns a pointer to the oldest dmi_error_t removed from the queue, or nullptr if context is nullptr or the error queue is empty.

Errors

None.

Examples

dmi_error_t *error;

while ((error = dmi_error_get_first(context)) != nullptr) {
    fprintf(stderr, "%s:%d: %s\n",
            error->function,
            error->line,
            dmi_error_message(error->reason));
}