<p>The main goals of libvirt when it comes to error handling are:</p>
<ul><li>provide as much detail as possible</li><li>provide the information as soon as possible</li><li>dont force the library user into one style of error handling</li></ul>
<p>As result the library provide both synchronous, callback based and
call it with the error information</li><li>otherwise if there is a global callback set with <ahref="html/libvirt-virterror.html#virSetErrorFunc">virSetErrorFunc</a>,
call it with the error information</li><li>otherwise call <ahref="html/libvirt-virterror.html#virDefaultErrorFunc">virDefaultErrorFunc</a>
on stderr</li><li>save the error in the connection for later retrieval with <ahref="html/libvirt-virterror.html#virConnGetLastError">virConnGetLastError</a></li></ol></li><li>otherwise like when failing to create an hypervisor connection:
on stderr</li><li>save the error in the connection for later retrieval with <ahref="html/libvirt-virterror.html#virGetLastError">virGetLastError</a></li></ol></li></ol>
<p>In all cases the error information is provided as a <ahref="html/libvirt-virterror.html#virErrorPtr">virErrorPtr</a> pointer to
<ul><li>code: an error number from the <ahref="html/libvirt-virterror.html#virErrorNumber">virErrorNumber</a>
enum</li><li>domain: an enum indicating which part of libvirt raised the error see
<ahref="html/libvirt-virterror.html#virErrorDomain">virErrorDomain</a></li><li>level: the error level, usually VIR_ERR_ERROR, though there is room for
warnings like VIR_ERR_WARNING</li><li>message: the full human-readable formatted string of the error</li><li>conn: if available a pointer to the <ahref="html/libvirt-libvirt.html#virConnectPtr">virConnectPtr</a>
connection to the hypervisor where this happened</li><li>dom: if available a pointer to the <ahref="html/libvirt-libvirt.html#virDomainPtr">virDomainPtr</a> domain
targeted in the operation</li></ul>
<p>and then extra raw information about the error which may be initialized
to 0 or NULL if unused</p>
<ul><li>str1, str2, str3: string information, usually str1 is the error
libvirt print the error on stderr by calling <ahref="html/libvirt-virterror.html#virDefaultErrorFunc">virDefaultErrorFunc</a>.
For asynchronous error handing, set such a function doing nothing to avoid
the error being reported on stderr, and call virConnGetLastError or
virGetLastError when an API call returned an error value. It can be a good
idea to use <ahref="html/libvirt-virterror.html#virResetLastError">virResetError</a> or <ahref="html/libvirt-virterror.html#virConnResetLastError">virConnResetLastError</a>