check whether actually an error occured when the search result is undef; check $@ for that (instead of $imap->LastError); distinguish warnings from error messages Mail::IMAPClient
authorMatthias Förste foerste@schlittermann.de
Wed, 09 Nov 2011 21:08:32 +0100
branchMail::IMAPClient
changeset 10 d01a8cd90e33
parent 9 b420079cbad2
child 11 87ddf3322246
check whether actually an error occured when the search result is undef; check $@ for that (instead of $imap->LastError); distinguish warnings from error messages
isearch
--- a/isearch	Wed Nov 09 21:01:20 2011 +0100
+++ b/isearch	Wed Nov 09 21:08:32 2011 +0100
@@ -94,7 +94,7 @@
         if (   $e =~ /BAD Error in IMAP command EXAMINE: 8bit data in atom$/
             or $e =~ /NO Invalid mailbox name: /) {
 
-            warn "Can't examine '$_': $e\n";
+            warn "[WARN] Can't examine '$_': $e\n";
             print "Skipping $_ ...\n";
             next;
 
@@ -109,8 +109,7 @@
     print "Searching $_ ...\n";
     if (my $m = $imap->search($opts->{criteria})) {
         $mids->{$_} = $m;
-    } else {
-        my $e = $imap->LastError;
+    } elsif (my $e = $@) {
 
         # dovecots fts plugin may just crash and cause the connection to drop
         # (this happened when searching a mailbox containing just gzipped mail
@@ -118,8 +117,8 @@
         # 2011-11-02 14:59:13 IMAP(userid): Panic: file squat-trie.c: line 877 (squat_build_word): assertion failed: (i + bytelen <= size)
         # 2011-11-02 14:59:13 IMAP(userid): Error: Raw backtrace: imap [0x80f2fd1] -> imap [0x80f3052] -> imap [0x80f29a9] -> /usr/lib/dovecot/modules/imap/lib21_fts_squat_plugin.so [0xb744a50d] -> /usr/lib/dovecot/modules/imap/lib21_fts_squat_plugin.so(squat_trie_build_more+0x151) [0xb744a7a1] -> /usr/lib/dovecot/modules/imap/lib21_fts_squat_plugin.so [0xb7447a54] -> /usr/lib/dovecot/modules/imap/lib20_fts_plugin.so(fts_backend_build_more+0x2e) [0xb7453e7e] -> /usr/lib/dovecot/modules/imap/lib20_fts_plugin.so [0xb7456fb6] -> imap(mailbox_search_next_nonblock+0x2d) [0x80b6e7d] -> imap [0x806e221] -> imap(imap_search_start+0x150) [0x806e700] -> imap(cmd_search+0xff) [0x8064d2f] -> imap [0x8067c6c] -> imap [0x8067d09] -> imap(client_handle_input+0x2d) [0x8067e7d] -> imap(client_input+0x5f) [0x80687df] -> imap(io_loop_handler_run+0xe0) [0x80fbd80] -> imap(io_loop_run+0x20) [0x80fb1f0] -> imap(main+0x5ea) [0x80713ba] -> /lib/i686/cmov/libc.so.6(__libc_start_main+0xe5) [0xb75f1455] -> imap [0x8060351]
         # 2011-11-02 14:59:13 dovecot: Error: child 7559 (imap) killed with signal 6 (core dumps disabled)
-        if ($e eq 'socket closed while reading data from server') {
-            warn "Can't search '$_': $e\n";
+        if ($e =~ /socket closed while reading data from server/i) {
+            warn "[WARN] Can't search '$_': $e\n";
             $imap->connect
               or die "Could not connect to IMAP server: $@\n";
         } else {