Error though exception handling

  • Thread starter Rickard Sjostrom
  • Start date
R

Rickard Sjostrom

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
 
A

ara.t.howard

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
 

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

No members online now.

Forum statistics

Threads
474,209
Messages
2,571,088
Members
47,687
Latest member
IngridXxj

Latest Threads

Top