# Error though exception handling

**URL:** <https://www.ruby-forum.com/t/error-though-exception-handling/102014>\
**Category:** Ruby\
**Created:** [August 9, 2006, 8:39am UTC](https://www.ruby-forum.com/t/error-though-exception-handling/102014 "2006-08-09T08:39:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rickthemick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6bbea6/32.png) [@rickthemick](https://www.ruby-forum.com/u/rickthemick)\
**Post date:** [August 9, 2006, 8:39am UTC](https://www.ruby-forum.com/t/error-though-exception-handling/102014/1 "2006-08-09T08:39:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rickthemick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6bbea6/32.png) [@rickthemick](https://www.ruby-forum.com/u/rickthemick)\
**Post date:** [August 9, 2006, 4:19pm UTC](https://www.ruby-forum.com/t/error-though-exception-handling/102014/2 "2006-08-09T16:19:48Z")

</div>

On Wed, 9 Aug 2006, Rickard Sjostrom wrote:

> ```
> from ./check_proc.rb:157
> 
> ```
> 
> 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
