diff options
author | John Snow <jsnow@redhat.com> | 2021-11-11 09:37:16 -0500 |
---|---|---|
committer | John Snow <jsnow@redhat.com> | 2021-11-16 14:26:36 -0500 |
commit | 25de7f50121f251c45d111582d786db7ce0768d3 (patch) | |
tree | 49b303cf2f5d14b3e497a6d1084e3f9ef3ce0007 /python | |
parent | f26bd6ff21df2f1d155ca17eef360423b706ab7f (diff) | |
download | qemu-25de7f50121f251c45d111582d786db7ce0768d3.zip qemu-25de7f50121f251c45d111582d786db7ce0768d3.tar.gz qemu-25de7f50121f251c45d111582d786db7ce0768d3.tar.bz2 |
python/aqmp: fix ConnectError string method
When ConnectError is used to wrap an Exception that was initialized
without an error message, we are treated to a traceback with a rubbish
line like this:
... ConnectError: Failed to establish session:
Correct this to use the name of an exception as a fallback message:
... ConnectError: Failed to establish session: EOFError
Better!
Signed-off-by: John Snow <jsnow@redhat.com>
Reported-by: Thomas Huth <thuth@redhat.com>
Tested-by: Thomas Huth <thuth@redhat.com>
Message-id: 20211111143719.2162525-3-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'python')
-rw-r--r-- | python/qemu/aqmp/protocol.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/python/qemu/aqmp/protocol.py b/python/qemu/aqmp/protocol.py index 860b795..5190b33 100644 --- a/python/qemu/aqmp/protocol.py +++ b/python/qemu/aqmp/protocol.py @@ -79,7 +79,11 @@ class ConnectError(AQMPError): self.exc: Exception = exc def __str__(self) -> str: - return f"{self.error_message}: {self.exc!s}" + cause = str(self.exc) + if not cause: + # If there's no error string, use the exception name. + cause = exception_summary(self.exc) + return f"{self.error_message}: {cause}" class StateError(AQMPError): |