summaryrefslogtreecommitdiffstats
path: root/python/qemu/aqmp/error.py
diff options
context:
space:
mode:
authorPeter Maydell2021-09-28 14:07:32 +0200
committerPeter Maydell2021-09-28 14:07:32 +0200
commit6b54a31bf7b403672a798b6443b1930ae6c74dea (patch)
tree008a5de54698d843aba645fd9598544318758f06 /python/qemu/aqmp/error.py
parentMerge remote-tracking branch 'remotes/philmd/tags/integration-testing-2021092... (diff)
parentpython/aqmp-tui: Add syntax highlighting (diff)
downloadqemu-6b54a31bf7b403672a798b6443b1930ae6c74dea.tar.gz
qemu-6b54a31bf7b403672a798b6443b1930ae6c74dea.tar.xz
qemu-6b54a31bf7b403672a798b6443b1930ae6c74dea.zip
Merge remote-tracking branch 'remotes/jsnow-gitlab/tags/python-pull-request' into staging
Python Pull request # gpg: Signature made Mon 27 Sep 2021 20:24:39 BST # gpg: using RSA key F9B7ABDBBCACDF95BE76CBD07DEF8106AAFC390E # gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>" [full] # Primary key fingerprint: FAEB 9711 A12C F475 812F 18F2 88A9 064D 1835 61EB # Subkey fingerprint: F9B7 ABDB BCAC DF95 BE76 CBD0 7DEF 8106 AAFC 390E * remotes/jsnow-gitlab/tags/python-pull-request: (32 commits) python/aqmp-tui: Add syntax highlighting python: add optional pygments dependency python: Add entry point for aqmp-tui python/aqmp-tui: Add AQMP TUI python: Add dependencies for AQMP TUI python/aqmp: Add Coverage.py support python/aqmp: add LineProtocol tests python/aqmp: add AsyncProtocol unit tests python: bump avocado to v90.0 python/aqmp: add scary message python/aqmp: add asyncio_run compatibility wrapper python/aqmp: add _raw() execution interface python/aqmp: add execute() interfaces python/aqmp: Add message routing to QMP protocol python/pylint: disable no-member check python/aqmp: add QMP protocol support python/pylint: disable too-many-function-args python/aqmp: add QMP event support python/aqmp: add well-known QMP object models python/aqmp: add QMP Message format ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'python/qemu/aqmp/error.py')
-rw-r--r--python/qemu/aqmp/error.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/python/qemu/aqmp/error.py b/python/qemu/aqmp/error.py
new file mode 100644
index 0000000000..781f49b008
--- /dev/null
+++ b/python/qemu/aqmp/error.py
@@ -0,0 +1,50 @@
+"""
+AQMP Error Classes
+
+This package seeks to provide semantic error classes that are intended
+to be used directly by clients when they would like to handle particular
+semantic failures (e.g. "failed to connect") without needing to know the
+enumeration of possible reasons for that failure.
+
+AQMPError serves as the ancestor for all exceptions raised by this
+package, and is suitable for use in handling semantic errors from this
+library. In most cases, individual public methods will attempt to catch
+and re-encapsulate various exceptions to provide a semantic
+error-handling interface.
+
+.. admonition:: AQMP Exception Hierarchy Reference
+
+ | `Exception`
+ | +-- `AQMPError`
+ | +-- `ConnectError`
+ | +-- `StateError`
+ | +-- `ExecInterruptedError`
+ | +-- `ExecuteError`
+ | +-- `ListenerError`
+ | +-- `ProtocolError`
+ | +-- `DeserializationError`
+ | +-- `UnexpectedTypeError`
+ | +-- `ServerParseError`
+ | +-- `BadReplyError`
+ | +-- `GreetingError`
+ | +-- `NegotiationError`
+"""
+
+
+class AQMPError(Exception):
+ """Abstract error class for all errors originating from this package."""
+
+
+class ProtocolError(AQMPError):
+ """
+ Abstract error class for protocol failures.
+
+ Semantically, these errors are generally the fault of either the
+ protocol server or as a result of a bug in this library.
+
+ :param error_message: Human-readable string describing the error.
+ """
+ def __init__(self, error_message: str):
+ super().__init__(error_message)
+ #: Human-readable error message, without any prefix.
+ self.error_message: str = error_message