# Still having problems with exceptions in IMAP module

**URL:** <https://www.ruby-forum.com/t/still-having-problems-with-exceptions-in-imap-module/96972>\
**Category:** Ruby\
**Created:** [January 25, 2006, 3:11am UTC](https://www.ruby-forum.com/t/still-having-problems-with-exceptions-in-imap-module/96972 "2006-01-25T03:11:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![russellf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7bcc69/32.png) [@russellf](https://www.ruby-forum.com/u/russellf)\
**Post date:** [January 25, 2006, 3:11am UTC](https://www.ruby-forum.com/t/still-having-problems-with-exceptions-in-imap-module/96972/1 "2006-01-25T03:11:45Z")

</div>

I have this method defined in a program I use for checking access to  
IMAP accounts.

def tryIMAP (host, usessl, user, pass)  
retryc = false  
proto = usessl ? “IMAPS” : “IMAP”  
begin  
imap = Net::IMAP.new(host, usessl ? 993 : 143, usessl)  
rescue Net::IMAP::ByeResponseError =\> e  
imap.disconnect if imap  
STDERR.print “#{host} #{proto} #{e.to\_s}\n”;  
retryc = true  
rescue =\> e  
imap.disconnect if imap  
STDERR.print “#{host} #{proto} #{e.to\_s}\n”;  
return ‘aborted’  
end while retryc  
begin  
imap.login( user, pass)  
imap.logout  
imap.disconnect  
‘success’  
rescue Net::IMAP::NoResponseError  
‘failure’  
end  
end

As you can see I explicitly have a rescue clause for  
Net::IMAP::ByeResponseError but I still get the error raised at runtime  
☹

(Net::IMAP::ByeResponseError)948:in `receive_responses': * BYE Autologout; idle for too long from /usr/lib/ruby/1.8/net/imap.rb:932:in`synchronize’  
from /usr/lib/ruby/1.8/net/imap.rb:932:in `receive_responses' from /usr/lib/ruby/1.8/net/imap.rb:917:in`initialize’  
from /usr/lib/ruby/1.8/net/imap.rb:916:in `start' from /usr/lib/ruby/1.8/net/imap.rb:916:in`initialize’  
from test.rb:11:in `new' from test.rb:11:in`tryIMAP’  
from test.rb:149  
from test.rb:105:in `each' from test.rb:105 from test.rb:94:in`each’  
from test.rb:94  
from test.rb:93:in `open’  
from test.rb:93

I am testing several thousand accounts and this error happens at random  
places in the list on different runs.

Can anyone suggest where I go from here. I suspect this is a bug  
somewhere in imap.rb but I can’t reproduce this reliably. Sigh…

Russell
