diff options
author | Markus Armbruster <armbru@redhat.com> | 2015-12-18 16:35:12 +0100 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2016-01-13 15:16:17 +0100 |
commit | 8277d2aa58fe4f8f3ee394ea647ea652faf822a4 (patch) | |
tree | fbbde8c5f68714997853f8660136d8c2efec740d /memory_mapping.c | |
parent | 73eaa04777001e6d68181910ed36729528f77d74 (diff) | |
download | qemu-8277d2aa58fe4f8f3ee394ea647ea652faf822a4.zip qemu-8277d2aa58fe4f8f3ee394ea647ea652faf822a4.tar.gz qemu-8277d2aa58fe4f8f3ee394ea647ea652faf822a4.tar.bz2 |
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>
Diffstat (limited to 'memory_mapping.c')
0 files changed, 0 insertions, 0 deletions