From: nobu.nokada@... Date: 2005-01-22T10:55:40+09:00 Subject: Re: Catching TCPSocket errors Hi, At Sat, 22 Jan 2005 05:01:02 +0900, christoph.heindl@gmail.com wrote in [ruby-talk:127579]: > since i started network programming in ruby i wondered about the > differnt kind of errors raised. On the one site we have the SocketError > object, on the other site a multiplicity of Errno may occur > (Errno::ECONNREFUSED, Errno::EHOSTUNREACH, etc.) > This becomes quite inconvient to handle as my rescue block looks like > this: > > rescue IOError, Errno::ECONNREFUSED, Errno::ECONNRESET, > Errno::ETIMEDOUT, > Errno::ENETUNREACH, Errno::ENOTSOCK, Errno::EHOSTUNREACH, SocketError > => err Errno::* are all subclasses of SystemCallError. 1) rescue IOError, SystemCallError, SocketError => err 2) ErrorsOnSocket = [IOError, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::ENETUNREACH, Errno::ENOTSOCK, Errno::EHOSTUNREACH, SocketError] rescue *ErrorsOnSocket => err -- Nobu Nakada