diff options
-rw-r--r-- | include/libvirt/virterror.h | 2 | ||||
-rw-r--r-- | src/libvirt_public.syms | 6 | ||||
-rw-r--r-- | src/util/virerror.c | 35 |
3 files changed, 43 insertions, 0 deletions
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h index 3e7c7a02c7..5e58b6a3f9 100644 --- a/include/libvirt/virterror.h +++ b/include/libvirt/virterror.h @@ -344,6 +344,8 @@ void virResetLastError (void); void virResetError (virErrorPtr err); void virFreeError (virErrorPtr err); +int virGetLastErrorCode (void); +int virGetLastErrorDomain (void); const char * virGetLastErrorMessage (void); virErrorPtr virConnGetLastError (virConnectPtr conn); diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 958601b1a5..4f54b84f75 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -792,4 +792,10 @@ LIBVIRT_4.4.0 { virConnectBaselineHypervisorCPU; } LIBVIRT_4.1.0; +LIBVIRT_4.5.0 { + global: + virGetLastErrorCode; + virGetLastErrorDomain; +} LIBVIRT_4.4.0; + # .... define new API here using predicted next version number .... diff --git a/src/util/virerror.c b/src/util/virerror.c index c000b00436..93632dbdf7 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -272,6 +272,41 @@ virGetLastError(void) /** + * virGetLastErrorCode: + * + * Get the most recent error code (enum virErrorNumber). + * + * Returns the most recent error code, or VIR_ERR_OK if none is set. + */ +int +virGetLastErrorCode(void) +{ + virErrorPtr err = virLastErrorObject(); + if (!err) + return VIR_ERR_OK; + return err->code; +} + + +/** + * virGetLastErrorDomain: + * + * Get the most recent error domain (enum virErrorDomain). + * + * Returns a numerical value of the most recent error's origin, or VIR_FROM_NONE + * if none is set. + */ +int +virGetLastErrorDomain(void) +{ + virErrorPtr err = virLastErrorObject(); + if (!err) + return VIR_FROM_NONE; + return err->domain; +} + + +/** * virGetLastErrorMessage: * * Get the most recent error message |