Re: [PATCH 1/3] Add a virGetLastErrorMessage() function

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

 



On 05/10/2013 11:17 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> 
> Apps using libvirt will often have code like
> 
>    if (virXXXX() < 0) {
>       virErrorPtr err = virGetLastError();
>       fprintf(stderr, "Something failed: %s\n",
>               err && err->message ? err->message :
>               "unknown error");
>       return -1;
>    }
> 
> Checking for a NULL error object or message leads to very
> verbose code. A virGetLastErrorMessage() helper from libvirt
> can simplify this to
> 
>    if (virXXXX() < 0) {
>       fprintf(stderr, "Something failed: %s\n",
>               virGetLastErrorMessage());
>       return -1;
>    }
> 
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---
>  include/libvirt/virterror.h |  2 ++
>  src/libvirt_public.syms     |  5 +++++
>  src/util/virerror.c         | 21 +++++++++++++++++++++
>  3 files changed, 28 insertions(+)

ACK.  Client-side only, so it doesn't need RPC support.

Should we update examples/hellolibvirt/hellolibvirt.c to use it?

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

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]