Hi,
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
I still don't know if i catch all of them. Isn't there a more convient
way of catching just errors which might happen on TCPSocket?
regards,
christoph
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