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 <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht 2017-04-07 20:27:39 +02:00
parent e88a6bcf03
commit 2c6fac6449

View File

@ -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):