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

Russell Fulton wrote:
> Hi,
>    I have a program that I am using to do password auditing on various 
> IMAP servers.  It defines this method:
> 
> def tryIMAP (host, usessl, user, pass)
> 
>     proto = usessl ? "IMAPS" : "IMAP"
>    begin
>       imap = Net::IMAP.new(host, usessl ? 993 : 143, usessl)
>    rescue => e
>      imap.disconnect if imap
> STDERR.print "#{host} #{proto} #{e.to_s}\n";
>      raise RuntimeError, "#{proto} failed"
>    end
>   begin
>     imap.login( user, pass)
>     imap.logout
>     imap.disconnect
>     'success'
>   rescue Net::IMAP::NoResponseError
>     'failure'
>   end
> 
> end
> 
> But the rescue clause does not catch all errors:
> 
>  (Net::IMAP::ByeResponseError)948:in `receive_responses': * BYE 
> Autologout; idle for too long

[snip]

> 
> How can I catch these errors?

Change the rescue-line to:

> rescue Net::IMAP::NoResponseError, Net::IMAP::ByeResponseError, Net::IMAP::BadResponseError

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.

HTH

Stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFD1dLM9S2Eui6zfdQRAiiRAJ9CMxchp2129sP5srKNpFHhEUIIgQCfU+ov
4bEy3i+wvmei5HvOR8RYDKk=
=Y0JS
-----END PGP SIGNATURE-----