error catching question:

G

Greg Brondo

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.
 
M

Martin Hart

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:
[snip]

Any ideas why the begin/rescue didn't catch it?

Thanks,.
Greg B.

rescue by itself only catches StandardError and derivatives I think..

try

begin
#your code
rescue Exception => e
#your code
end
 
G

Greg Brondo

Martin said:
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:

[snip]

Any ideas why the begin/rescue didn't catch it?

Thanks,.
Greg B.


rescue by itself only catches StandardError and derivatives I think..

try

begin
#your code
rescue Exception => e
#your code
end

Thanks!

Greg B.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top