© W. David Ashley 2019
W. David AshleyFoundations of Libvirt Development https://doi.org/10.1007/978-1-4842-4862-1_8

8. Error Handling

W. David Ashley1 
(1)
Austin, TX, USA
 

The libvirt error functions are designed to give more detailed information about what caused a failure in the case that a normal libvirt function or method returns an error. An important thing to note about Python libvirt error reporting is that errors are stored on a per-thread basis and not per connection.

The libvirtError Class

The libvirt Python module defines a standard exception class called libvirtError that can be subclassed to add additional functionality when raising a libvirt exception. Listing 8-1 shows a partial definition of the libvirtError class definition.
class ...

Get Foundations of Libvirt Development: How to Set Up and Maintain a Virtual Machine Environment with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.