From: Michael Goldish Subject: [KVM-AUTOTEST PATCH] KVM test: kvm_monitor.py: add __str__() method to QMPCmdError exception Date: Mon, 18 Oct 2010 15:13:40 +0200 Message-ID: <1287407620-30026-4-git-send-email-mgoldish@redhat.com> References: <1287407620-30026-1-git-send-email-mgoldish@redhat.com> <1287407620-30026-2-git-send-email-mgoldish@redhat.com> <1287407620-30026-3-git-send-email-mgoldish@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: autotest@test.kernel.org, kvm@vger.kernel.org Return-path: In-Reply-To: <1287407620-30026-3-git-send-email-mgoldish@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: autotest-bounces@test.kernel.org Errors-To: autotest-bounces@test.kernel.org List-Id: kvm.vger.kernel.org Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_monitor.py | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) 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() -- 1.5.5.6