From 2c6fac6449a0f1ab79eb2f22fcff2c9d62f0dfcf Mon Sep 17 00:00:00 2001 From: Nicolas Sebrecht Date: Fri, 7 Apr 2017 20:27:39 +0200 Subject: [PATCH] folder/IMAP: improve handling of "matchinguids" error while searching headers Raise OfflineImapError instead of ValueError. Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/452 Signed-off-by: Nicolas Sebrecht --- offlineimap/folder/IMAP.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index e5a9742..b565dbc 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -392,9 +392,12 @@ class IMAPFolder(BaseFolder): self.ui.debug('imap', '__savemessage_searchforheader: matchinguids now ' + repr(matchinguids)) if len(matchinguids) != 1 or matchinguids[0] is None: - raise ValueError("While attempting to find UID for message with " - "header %s, got wrong-sized matchinguids of %s"% - (headername, str(matchinguids))) + raise OfflineImapError( + "While attempting to find UID for message with " + "header %s, got wrong-sized matchinguids of %s"% + (headername, str(matchinguids)), + OfflineImapError.ERROR.MESSAGE + ) return int(matchinguids[0]) def __savemessage_fetchheaders(self, imapobj, headername, headervalue):