qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 09/23] error: New error_prepend(), error_repo


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v2 09/23] error: New error_prepend(), error_reportf_err()
Date: Thu, 17 Dec 2015 13:23:31 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 12/17/2015 09:49 AM, Markus Armbruster wrote:
> 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));

Did you intend to have literal TABs in the commit message?

>     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 <address@hidden>
> ---
>  include/qapi/error.h | 31 +++++++++++++++++++++++++++++--
>  util/error.c         | 33 +++++++++++++++++++++++++++++++++
>  2 files changed, 62 insertions(+), 2 deletions(-)
> 

Reviewed-by: Eric Blake <address@hidden>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]