Home
last modified time | relevance | path

Searched hist:"8277 d2aa" (Results 1 – 2 of 2) sorted by relevance

/openbmc/qemu/util/
H A Derror.c8277d2aa Fri Dec 18 09:35:12 CST 2015 Markus Armbruster <armbru@redhat.com> error: New error_prepend(), error_reportf_err()

Instead of simply propagating an error verbatim, we sometimes want to
add to its message, like this:

frobnicate(arg, &err);
error_setg(errp, "Can't frobnicate %s: %s",
arg, error_get_pretty(err));
error_free(err);

This is suboptimal, because it loses err's hint (if any). Moreover,
when errp is &error_abort or is subsequently propagated to
&error_abort, the abort message points to the place where we last
added to the error, not to the place where it originated.

To avoid these issues, provide means to add to an error's message in
place:

frobnicate(arg, errp);
error_prepend(errp, "Can't frobnicate %s: ", arg);

Likewise, reporting an error like

frobnicate(arg, &err);
error_report("Can't frobnicate %s: %s", arg, error_get_pretty(err));

can lose err's hint. To avoid:

error_reportf_err(err, "Can't frobnicate %s: ", arg);

The next commits will put these functions to use.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450452927-8346-10-git-send-email-armbru@redhat.com>
/openbmc/qemu/include/qapi/
H A Derror.h8277d2aa Fri Dec 18 09:35:12 CST 2015 Markus Armbruster <armbru@redhat.com> error: New error_prepend(), error_reportf_err()

Instead of simply propagating an error verbatim, we sometimes want to
add to its message, like this:

frobnicate(arg, &err);
error_setg(errp, "Can't frobnicate %s: %s",
arg, error_get_pretty(err));
error_free(err);

This is suboptimal, because it loses err's hint (if any). Moreover,
when errp is &error_abort or is subsequently propagated to
&error_abort, the abort message points to the place where we last
added to the error, not to the place where it originated.

To avoid these issues, provide means to add to an error's message in
place:

frobnicate(arg, errp);
error_prepend(errp, "Can't frobnicate %s: ", arg);

Likewise, reporting an error like

frobnicate(arg, &err);
error_report("Can't frobnicate %s: %s", arg, error_get_pretty(err));

can lose err's hint. To avoid:

error_reportf_err(err, "Can't frobnicate %s: ", arg);

The next commits will put these functions to use.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450452927-8346-10-git-send-email-armbru@redhat.com>