mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Add a virGetLastErrorMessage() function
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@redhat.com>
This commit is contained in:
@@ -313,6 +313,8 @@ void virResetLastError (void);
|
||||
void virResetError (virErrorPtr err);
|
||||
void virFreeError (virErrorPtr err);
|
||||
|
||||
const char * virGetLastErrorMessage (void);
|
||||
|
||||
virErrorPtr virConnGetLastError (virConnectPtr conn);
|
||||
void virConnResetLastError (virConnectPtr conn);
|
||||
int virCopyLastError (virErrorPtr to);
|
||||
|
||||
Reference in New Issue
Block a user