From: Yu-shan Fung Date: 2008-11-14T09:43:54+09:00 Subject: Unable to rescue Errno::ECONNRESET during For some reason my rescue clause is not catching this exception. Here's the stack trace: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/openssl/buffering.rb:35:in `sysread': Connection reset by peer (Errno::ECONNRESET) from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/openssl/buffering.rb:35:in `fill_rbuff' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/openssl/buffering.rb:106:in `gets' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/imap.rb:991:in `get_response' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/imap.rb:929:in `receive_responses' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/imap.rb:922:in `initialize' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/imap.rb:921:in `start' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/imap.rb:921:in `initialize' from batch/test.rb:6:in `new' from batch/test.rb:6 from batch/test.rb:4:in `loop' from batch/test.rb:4 This is the line in test.rb where the error occurs: imap = Net::IMAP.new('imap.gmail.com', 993, true) Here's my test code: loop do begin imap = Net::IMAP.new('imap.gmail.com', 993, true) imap.login('xxxxx', 'yyyyy') imap.select('Inbox') imap.expunge imap.logout $stdout.putc '.' $stdout.flush rescue Net::IMAP::NoResponseError => e puts "IMAP no response" rescue Net::IMAP::ByeResponseError => e # send to log file, db, or email puts "IMAP bye response" rescue Errno::ECONNRESET => e puts "Connection reset by peer" puts e.backtrace rescue Exception => e puts "IMAP Error-#{e.class}\n#{e.message}" puts e.backtrace end sleep 1 end Either the Errno::RCONNRESET or the the Exception clause should catch the exception, print the error and continue right? But each time it hits the ECONNRESET error, it terminates. Any idea why? Thanks a bunch! -- Posted via http://www.ruby-forum.com/.