[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFC 19/32] python//qmp.py: add QMPProtocolError
From: |
John Snow |
Subject: |
[PATCH RFC 19/32] python//qmp.py: add QMPProtocolError |
Date: |
Thu, 14 May 2020 01:53:50 -0400 |
In the case that we receive a reply but are unable to understand it, use
this exception name to indicate that case.
Signed-off-by: John Snow <address@hidden>
---
python/qemu/lib/qmp.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/python/qemu/lib/qmp.py b/python/qemu/lib/qmp.py
index e460234f2e..5fb16f4b42 100644
--- a/python/qemu/lib/qmp.py
+++ b/python/qemu/lib/qmp.py
@@ -62,6 +62,12 @@ class QMPTimeoutError(QMPError):
"""
+class QMPProtocolError(QMPError):
+ """
+ QMP protocol error; unexpected response
+ """
+
+
class QMPResponseError(QMPError):
"""
Represents erroneous QMP monitor reply
@@ -265,6 +271,10 @@ def command(self, cmd, **kwds):
ret = self.cmd(cmd, kwds)
if 'error' in ret:
raise QMPResponseError(ret)
+ if 'return' not in ret:
+ raise QMPProtocolError(
+ "'return' key not found in QMP response '{}'".format(str(ret))
+ )
return cast(QMPReturnValue, ret['return'])
def pull_event(self, wait=False):
--
2.21.1
- [PATCH RFC 25/32] python//machine.py: Handle None events in event_wait, (continued)
- [PATCH RFC 25/32] python//machine.py: Handle None events in event_wait, John Snow, 2020/05/14
- [PATCH RFC 26/32] python//machine.py: use qmp.command, John Snow, 2020/05/14
- [PATCH RFC 28/32] python//machine.py: fix _popen access, John Snow, 2020/05/14
- [PATCH RFC 27/32] python//machine.py: Add _qmp access shim, John Snow, 2020/05/14
- [PATCH RFC 29/32] python//qtest.py: Check before accessing _qtest, John Snow, 2020/05/14
- [PATCH RFC 12/32] python/qemu/lib: fix socket.makefile() typing, John Snow, 2020/05/14
- [PATCH RFC 31/32] python/qemu: add mypy to Pipfile, John Snow, 2020/05/14
- [PATCH RFC 19/32] python//qmp.py: add QMPProtocolError,
John Snow <=
- [PATCH RFC 13/32] python/qemu/lib: Adjust traceback typing, John Snow, 2020/05/14
- [PATCH RFC 30/32] python/qemu/lib: make 'args' style arguments immutable, John Snow, 2020/05/14
- [PATCH RFC 32/32] python/qemu/lib: Add mypy type annotations, John Snow, 2020/05/14
- Re: [PATCH RFC 00/32] python/qemu: refactor as installable package, Philippe Mathieu-Daudé, 2020/05/18
- Re: [PATCH RFC 00/32] python/qemu: refactor as installable package, John Snow, 2020/05/21