From 65e4f18bb4ecd47e5596d394808c454d2572de71 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Wed, 6 Apr 2022 13:54:34 +0800 Subject: [PATCH 1/2] format exception using traceback.format_exception_only for error messages because many exceptions return empty strings for `str(exc)`, or lack information (e.g. the exception name). --- offlineimap/ui/UIBase.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/offlineimap/ui/UIBase.py b/offlineimap/ui/UIBase.py index 3c6859c..b85725f 100644 --- a/offlineimap/ui/UIBase.py +++ b/offlineimap/ui/UIBase.py @@ -538,10 +538,11 @@ class UIBase: exitstatus = 1 while not self.exc_queue.empty(): msg, exc, exc_traceback = self.exc_queue.get() + exc_str = "".join(traceback.format_exception_only(type(exc), exc)) if msg: - self.warn("ERROR: %s\n %s" % (msg, exc)) + self.warn("ERROR: %s\n %s" % (msg, exc_str)) else: - self.warn("ERROR: %s" % exc) + self.warn("ERROR: %s" % exc_str) if exc_traceback: self.warn("\nTraceback:\n%s" % "".join( traceback.format_tb(exc_traceback))) From 206322b1517babfa49cc6201f5817f4ffcdc4e10 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Wed, 6 Apr 2022 18:18:24 +0800 Subject: [PATCH 2/2] remove a stray expression --- offlineimap/imapserver.py | 1 - 1 file changed, 1 deletion(-) diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py index bc2ab5f..3b98712 100644 --- a/offlineimap/imapserver.py +++ b/offlineimap/imapserver.py @@ -689,7 +689,6 @@ class IMAPServer: OfflineImapError.ERROR.CRITICAL) except: pass - e.args[0][:35] # re-raise all other errors raise