Catch exceptions from IMAP library.