From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: Thomas Huth <thuth@redhat.com>, John Snow <jsnow@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>,
Cleber Rosa <crosa@redhat.com>
Subject: [PATCH 2/5] python/aqmp: fix ConnectError string method
Date: Thu, 11 Nov 2021 09:37:16 -0500 [thread overview]
Message-ID: <20211111143719.2162525-3-jsnow@redhat.com> (raw)
In-Reply-To: <20211111143719.2162525-1-jsnow@redhat.com>
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>
---
python/qemu/aqmp/protocol.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/python/qemu/aqmp/protocol.py b/python/qemu/aqmp/protocol.py
index 860b79512d..5190b33b13 100644
--- a/python/qemu/aqmp/protocol.py
+++ b/python/qemu/aqmp/protocol.py
@@ -79,7 +79,11 @@ def __init__(self, error_message: str, exc: Exception):
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):
--
2.31.1
next prev parent reply other threads:[~2021-11-11 14:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-11 14:37 [PATCH 0/5] python/aqmp: improve support for device-crash-test John Snow
2021-11-11 14:37 ` [PATCH 1/5] python/aqmp: Fix disconnect during capabilities negotiation John Snow
2021-11-11 14:37 ` John Snow [this message]
2021-11-11 14:37 ` [PATCH 3/5] scripts/device-crash-test: simplify Exception handling John Snow
2021-11-11 14:37 ` [PATCH 4/5] scripts/device-crash-test: don't emit AQMP connection errors to stdout John Snow
2021-11-11 14:37 ` [PATCH 5/5] scripts/device-crash-test: hide tracebacks for QMP connect errors John Snow
2021-11-12 7:20 ` [PATCH 0/5] python/aqmp: improve support for device-crash-test Thomas Huth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211111143719.2162525-3-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).