Skip to content
Snippets Groups Projects
Commit 25de7f50 authored by John Snow's avatar John Snow
Browse files

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: default avatarJohn Snow <jsnow@redhat.com>
Reported-by: default avatarThomas Huth <thuth@redhat.com>
Tested-by: default avatarThomas Huth <thuth@redhat.com>
Message-id: 20211111143719.2162525-3-jsnow@redhat.com
Signed-off-by: default avatarJohn Snow <jsnow@redhat.com>
parent f26bd6ff
No related branches found
No related tags found
No related merge requests found
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment