diff mbox

[KVM-AUTOTEST] KVM test: kvm_monitor.py: add __str__() method to QMPCmdError exception

Message ID 1287407620-30026-4-git-send-email-mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Oct. 18, 2010, 1:13 p.m. UTC
None
diff mbox

Patch

diff --git a/client/tests/kvm/kvm_monitor.py b/client/tests/kvm/kvm_monitor.py
index b887060..40be77d 100644
--- a/client/tests/kvm/kvm_monitor.py
+++ b/client/tests/kvm/kvm_monitor.py
@@ -38,7 +38,9 @@  class MonitorNotSupportedError(MonitorError):
 
 
 class QMPCmdError(MonitorError):
-    pass
+    def __str__(self):
+        return ("QMP command '%s' failed (arguments: %r, error message: %r)" %
+                tuple(self.args))
 
 
 class Monitor:
@@ -501,8 +503,8 @@  class QMPMonitor(Monitor):
         @raise MonitorSendError: Raised if the command cannot be sent
         @raise MonitorProtocolError: Raised if no response is received
         @raise QMPCmdError: Raised if the response is an error message
-                (the exception's args are (msg, data) where msg is a string and
-                data is the error data)
+                (the exception's args are (cmd, args, data) where data is the
+                error data)
         """
         if not self._acquire_lock(20):
             raise MonitorLockError("Could not acquire exclusive lock to send "
@@ -524,7 +526,7 @@  class QMPMonitor(Monitor):
             if "return" in r:
                 return r["return"]
             if "error" in r:
-                raise QMPCmdError("QMP command '%s' failed" % cmd, r["error"])
+                raise QMPCmdError(cmd, args, r["error"])
 
         finally:
             self._lock.release()