error catching question:

Discussion in 'Ruby' started by Greg Brondo, Apr 12, 2004.

  1. Greg Brondo

    Greg Brondo Guest

    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.
    Greg Brondo, Apr 12, 2004
    #1
    1. Advertising

  2. Greg Brondo

    Martin Hart Guest

    On Monday 12 Apr 2004 4:24 pm, Greg Brondo wrote:
    > 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

    --
    Martin Hart
    Arnclan Limited
    Union Street, Dunstable, LU6 1EX
    http://www.arnclan.com
    Martin Hart, Apr 12, 2004
    #2
    1. Advertising

  3. Greg Brondo

    Greg Brondo Guest

    Martin Hart wrote:
    > On Monday 12 Apr 2004 4:24 pm, Greg Brondo wrote:
    >
    >>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.
    Greg Brondo, Apr 12, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. PapaBear
    Replies:
    2
    Views:
    1,225
  2. Saya

    Catching HTTP error

    Saya, Aug 30, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    526
    victor
    Aug 31, 2005
  3. chanko

    catching error url

    chanko, Mar 27, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    332
    chanko
    Mar 27, 2006
  4. interpim
    Replies:
    4
    Views:
    378
    those who know me have no need of my name
    Jan 2, 2004
  5. Erik Max Francis

    Easy question on error catching

    Erik Max Francis, Apr 12, 2004, in forum: Python
    Replies:
    2
    Views:
    266
    Andrew Dalke
    Apr 12, 2004
Loading...

Share This Page