diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2008-08-22 10:50:18 +0000 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2008-08-22 10:50:18 +0000 |
commit | d3f74f092b16afce7c651884e811a56abc420c4f (patch) | |
tree | be7a51bfa31ec998d1f9e345d808d54c8123c451 | |
parent | b4f22f829d70a1ddc141a2c12229336907f0bbe9 (diff) | |
download | libvirt-python-v6-d3f74f092b16afce7c651884e811a56abc420c4f.tar.gz libvirt-python-v6-d3f74f092b16afce7c651884e811a56abc420c4f.tar.xz libvirt-python-v6-d3f74f092b16afce7c651884e811a56abc420c4f.zip |
Use libvirt error message for python exceptionsv0.4.6LIBVIRT_0_4_6
-rw-r--r-- | libvir.py | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -15,8 +15,7 @@ import types # The root of all libvirt errors. class libvirtError(Exception): - def __init__(self, msg, conn=None, dom=None, net=None, pool=None, vol=None): - Exception.__init__(self, msg) + def __init__(self, defmsg, conn=None, dom=None, net=None, pool=None, vol=None): if dom is not None: conn = dom._conn @@ -28,9 +27,17 @@ class libvirtError(Exception): conn = vol._conn if conn is None: - self.err = virGetLastError() + err = virGetLastError() + else: + err = conn.virConnGetLastError() + if err is None: + msg = defmsg else: - self.err = conn.virConnGetLastError() + msg = err[2] + + Exception.__init__(self, msg) + + self.err = err def get_error_code(self): if self.err is None: @@ -77,12 +84,6 @@ class libvirtError(Exception): return None return self.err[8] - def __str__(self): - if self.get_error_message() is None: - return Exception.__str__(self) - else: - return Exception.__str__(self) + " " + self.get_error_message() - # # register the libvirt global error handler # |