-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sat, 18 Jan 2003 17:49, Shashank Date wrote:
> How do I get the type (class)  of exception thrown by any given peice of
> code ?
>
> I was playing with sockets and wanted to rescue the "<Errno::E10061: No
> connection could be made..." exception.
>
> My dumb way was to try and guess it by looking at the heirarchy tree on
> Page 93 of PickAxe. After a couple of wrong guesses finally found out it
> was RuntimeError. But what if it was none of those (like the TimeoutError)?
>
> Surely, there is a smart (Ruby) way to do this ?
>
> -- shanko

Maybe something like this helps you?

irb(main):003:0> class MyError < StandardError
irb(main):004:1> end
=> nil
irb(main):005:0> def meth
irb(main):006:1> raise(MyError, 'Error here')
irb(main):007:1> end
=> nil
irb(main):009:0> begin
irb(main):010:1* meth
irb(main):011:1> rescue StandardError => e
irb(main):012:1> puts e.type.to_s
irb(main):013:1> end
MyError
=> nil

- -- 
Signed,
Holden Glova
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD4DBQE+KOML0X8w8X71zPcRAlIEAJ0fnXN2r6LHrRbliHWh8FSxg4f2JQCXaSJQ
QWPMp5NBPX0g9ohptf6x3w==
=Wd5A
-----END PGP SIGNATURE-----