]> code.delx.au - offlineimap/commitdiff
make savemessage_searchforheader more robust
authorAdam Spiers <darcs@adamspiers.org>
Mon, 15 May 2006 02:51:12 +0000 (03:51 +0100)
committerAdam Spiers <darcs@adamspiers.org>
Mon, 15 May 2006 02:51:12 +0000 (03:51 +0100)
offlineimap/folder/IMAP.py

index d28825501993c68e09ca75d1dd9b6b702eaf1017..45978b592b625e136b1f1a2471548a1a1db70cbf 100644 (file)
@@ -159,11 +159,14 @@ class IMAPFolder(BaseFolder):
         headervalue = imapobj._quote(headervalue)
         try:
             matchinguids = imapobj.uid('search', 'HEADER', headername, headervalue)[1][0]
-        except imapobj.error:
+        except imapobj.error, err:
             # IMAP server doesn't implement search or had a problem.
-            return 0
+            raise ValueError, "Got IMAP error while attempting to find UID for message with header %s: %s" % (headername, err)
         ui.debug('imap', 'savemessage_searchforheader got initial matchinguids: ' + repr(matchinguids))
-               
+
+        if matchinguids == '':
+            raise ValueError, "Search for UID for message with header %s yielded no results" % headername
+
         matchinguids = matchinguids.split(' ')
         ui.debug('imap', 'savemessage_searchforheader: matchinguids now ' + \
                  repr(matchinguids))