summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2008-08-22 10:50:18 +0000
committerDaniel P. Berrange <berrange@redhat.com>2008-08-22 10:50:18 +0000
commitd3f74f092b16afce7c651884e811a56abc420c4f (patch)
treebe7a51bfa31ec998d1f9e345d808d54c8123c451
parentb4f22f829d70a1ddc141a2c12229336907f0bbe9 (diff)
downloadlibvirt-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.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/libvir.py b/libvir.py
index 784152a..cf5e776 100644
--- a/libvir.py
+++ b/libvir.py
@@ -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
#