I have some code that checks a pop3 email box for me. It is wrapped in a
begin/rescue clause. However, somehow it seems to have escaped the rescue
clause:
/usr/lib/ruby/1.8/net/protocol.rb:197:in rbuf_fill': socket read timeout (60 sec) (Timeout::Error) from /usr/lib/ruby/1.8/net/protocol.rb:160:in
readuntil’
from /usr/lib/ruby/1.8/net/protocol.rb:178:in each_message_chunk' from /usr/lib/ruby/1.8/net/pop.rb:791:in
retr’
from /usr/lib/ruby/1.8/net/pop.rb:789:in critical' from /usr/lib/ruby/1.8/net/pop.rb:792:in
retr’
from /usr/lib/ruby/1.8/net/pop.rb:648:in pop' from fido.rb:33:in
checkNewRequests’
from fido.rb:31:in each' from /usr/lib/ruby/1.8/net/pop.rb:517:in
each’
from fido.rb:31:in checkNewRequests' from fido.rb:30:in
start’
from /usr/lib/ruby/1.8/net/pop.rb:323:in start' from fido.rb:30:in
checkNewRequests’
from fido.rb:20:in `start’
from fido.rb:161
Here’s the code:
def checkNewRequests()
begin
Net::POP3.start(“mta.algx.net”, 110, “blah”, “passblah”) { |pop|
pop.each { |msg|
puts “Checking msg #{msg.id}” if DEBUG
if msg.pop =~ /Subject: [fF]ido/
if msg.pop =~ /–reload–/
printInfo(“Agent reload requested”)
loadAgents()
msg.delete
else # process request
mailMsg = MailMsg.new(msg)
request = Request.new(mailMsg.agentList)
success = request.doAgents
printInfo(“Success = #{success}”)
if success
printInfo(“Sending response to
#{mailMsg.from}”)
sendEmail(mailMsg.from, request.getResponse)
msg.delete
end
end
end
}
}
rescue
printInfo(“Problem checking email…retrying in 30 seconds”)
sleep 30
end
end
Any ideas why the begin/rescue didn’t catch it?
Thanks,.
Greg B.