Well... I found out the error.

I think you could catch with error
with Errno::ETIMEDOUT

it is NOT ETIMEOUT. I missed a 'D'!!!

That should handle HTTP case as well.

Hubert



hubert / cs.nyu.edu (Hubert Hung-Hsien Chang) wrote in message news:<98ba0902.0203011710.30135628 / posting.google.com>...
> I am playing around with the Net::HTTP
> and I want my crawler ( agent, if you like)
> to catch the Net::HTTPRequestTimeOut
> 
> Here is what I do...
> 
> agent = Net::HTTP.new('www.cnn.com', 80)
> 
> # I have tried to add this but it doesn't work either#
> agent.open_timeout = 5
> 
> begin
>   resp, data = agent.get(url, nil)
> 
>   rescue Net::HTTPRequestTimeOut => details
>      return NIL
> 
> end
> 
> I got error
> /ruby/lib/ruby/1.6/net/protocol.rb:73:in `get': class or module
> required for rescue clause (TypeError)
> 
> So what is the right way to do it?
> I add in other rescue and it seems fine to me except when I add
> Net::HTTPRequestTimeOut
> Net::HTTPGatewayTimeOut
> Errno::ETIMEOUT
> 
> Any idea?