3.9. Handling Errors

Where errors are encountered the Software Development Kit uses exceptions to highlight them. The Software Development Kit defines exception types in addition to those defined by the Python interpreter itself. These exceptions are located in the ovirtsdk.infrastructure.errors module:
ConnectionError
Raised when a transport layer error has occurred.
DisconnectedError
Raised when attempting to use SDK after it was explicitly disconnected.
ImmutableError
Raised when initiating SDK while an SDK instance already exists under the same domain. Applicable to SDK version 3.2 and higher.
NoCertificatesError
Raised when no CA is provided and --insecure is 'False'.
RequestError
Raised at any kind of oVirt server error.
UnsecuredConnectionAttemptError
Raised when HTTP protocol is used while server is running HTTPS.
MissingParametersError
Raised when you are trying to use get() method without providing either id or name.
These exceptions can be caught and handled like any other Python exception:

Example 3.9. Catching a ConnectionError Exception

from ovirtsdk.api import API
from ovirtsdk.xml import params

try:
    api = API(url="https://HOST",
              user="USER,
              pass="PASS,
              ca_file="/etc/pki/ovirt-engine/ca.pem")
except ConnectionError, err:
    print "Connection failed: %s" % err