From: Brian Candler Date: 2009-12-09T00:31:49+09:00 Subject: Re: Newbie question: what exceptions are thrown by FTP class The Net::FTP documentation does tell you some exceptions that it can raise, and if you really care about the detail you can just look at the source, since it's all written in Ruby, and at the top you'll find module Net # :stopdoc: class FTPError < StandardError; end class FTPReplyError < FTPError; end class FTPTempError < FTPError; end class FTPPermError < FTPError; end class FTPProtoError < FTPError; end # :startdoc: But often you don't care. Exceptions form a hierarchy, and the ones you want to catch are usually either under StandardError or RuntimeError (itself a subclass of StandardError) A simple "rescue" by itself is the same as "rescue StandardError". If you want to capture *all* exceptions then rescue Exception, but this is usually not a good idea as it will also capture fatal errors - e.g. NoMemoryError, SyntaxError, and Interrupt (ctrl-C) For Net::FTP I would suggest: begin ... rescue IOError, SystemCallError, Net::FTPError ... end to catch everything socket-related and any protocol errors raised within Net::FTP, without catching things which are normally programmer bugs like NameError or ArgumentError. Google "ruby exception hierarchy" for more info. -- Posted via http://www.ruby-forum.com/.