Forum: Ruby on Rails Can I catch something like Errno::EBADF with rescue?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Wes G. (Guest)
on 2006-04-18 03:44
All,

I am using Net::HTTP to make requests for URLs in my app.  When I get a
bad server, I get "Bad file descriptor - connect(2)" message on a
ERRNO:EBADF error.

Can I catch with rescue or otherwise gracefully react to that error?

Thanks,
Wes
Matthew P. (Guest)
on 2006-04-18 04:00
(Received via mailing list)
On Tue, Apr 18, 2006 at 01:44:25AM +0200, Wes G. wrote:
> I am using Net::HTTP to make requests for URLs in my app.  When I get a
> bad server, I get "Bad file descriptor - connect(2)" message on a
> ERRNO:EBADF error.
>
> Can I catch with rescue or otherwise gracefully react to that error?

Of course.

begin
  # code
rescue Errno::EBADF => e
  # handle me, baby!
end

- Matt
Wes G. (Guest)
on 2006-04-18 04:02
I just caught it by mistake when I saw this.

I was making a Java distinction between Errno and Exception - there is
probably some diff. that I don't understand yet, but this will work for
now!!!

Thanks,
Wes


Matthew P. wrote:
> On Tue, Apr 18, 2006 at 01:44:25AM +0200, Wes G. wrote:
>> I am using Net::HTTP to make requests for URLs in my app.  When I get a
>> bad server, I get "Bad file descriptor - connect(2)" message on a
>> ERRNO:EBADF error.
>>
>> Can I catch with rescue or otherwise gracefully react to that error?
>
> Of course.
>
> begin
>   # code
> rescue Errno::EBADF => e
>   # handle me, baby!
> end
>
> - Matt
This topic is locked and can not be replied to.