From: Stefan Mahlitz Date: 2006-01-27T04:40:44+09:00 Subject: Re: Net::imap exceptions Russell Fulton wrote: > Stefan Mahlitz wrote: > > Thanks for your response Stefan! > >>> How can I catch these errors? >> Change the rescue-line to: >> >>> rescue Net::IMAP::NoResponseError, Net::IMAP::ByeResponseError, Net::IMAP::BadResponseError > > That was going to be my next try. Hmmm.... last time I tried putting > more than one exception on a rescue statement I got a syntax error?? > I'll try again -- must have been some other issue. > >> and so on. Maybe it helps to rescue Net::IMAP::Error only, but can't >> have a look at the implementation of the other exceptions at the moment. >> > > Just a check on my understanding of how things *should* work: > > I thought that an unadorned "rescue" *should* catch *all* exceptions. > Is this correct? Should I file a bug report? Where to? No, it will only catch all Exceptions that are derived from StandardError (as I read Pickaxe II, page 108). Figure 8.1 on page 109 could be helpful. The exception gets thrown in > imap = Net::IMAP.new(host, usessl ? 993 : 143, usessl) as the backtrace tells: > ... > from /usr/lib/ruby/1.8/net/imap.rb:916:in `initialize' > from test.rb:11:in `new' > from test.rb:11:in `tryIMAP' > ... and on line 12 is only the standard rescue > rescue => e If you add the IMAP-Exceptions there it should work (and raise a RuntimeException).