On Wed, 9 Aug 2006, Rickard Sjostrom wrote:

> Hi!
> I get this error:
>
> --------------------------
> /app/ruby/1.8.4/lib/ruby/1.8/net/telnet.rb:551:in `waitfor': timed out
> while waiting for more data (Timeout::Error)
>        from ./proc_ctrl/telnetcom.rb:44:in `alive?'
>        from ./proc_ctrl/proc_manager.rb:91:in `check_procs_status'
>        from ./proc_ctrl/proc_manager.rb:90:in `check_procs_status'
>        from ./check_proc.rb:140:in `main'
>        from ./check_proc.rb:157
> --------------------------
>
> though my code looks like this (shortend), line 44 marked:
>
> --------------------------
> begin
>        telnet_srv = Net::Telnet.new("Host" => @address, "Port" =>
> @port,
>                                 "Telnetmode" => false, "Prompt" =>
> prompt)
>
>        telnet_srv.waitfor("Match" => prompt) #LINE 44
>
>        response = telnet_srv.cmd("String" => @cmd, "Match" =>
> prompt).gsub(prompt, "")
>
> rescue
>   #do some rescuing
> end
> --------------------------
>
> How can it raise that Timeout::Error when I use the begin/rescue
> statement?
>
> Thanks!
> /Rick

that's not how rescue works:

   harp:~ > irb -r timeout
   irb(main):001:0> begin; Timeout.timeout(1){ sleep 2 }; rescue Timeout::Error; p 42; end
   42
   => nil

   irb(main):002:0> StandardError === Timeout::Error
   => false

by default it rescues only children of StandardError - you must specify otherwise.

-a
-- 
to foster inner awareness, introspection, and reasoning is more efficient than
meditation and prayer.
- h.h. the 14th dali lama