Patch series for proper error messages

Sebastian Spaeth Sebastian at SSpaeth.de
Wed May 4 15:44:33 BST 2011


OK, following a patch series that lays the foundation for proper error
messages rather than always (often obscure) traceback "crashes".
We can throw OfflineImapErrors or severity MESSAGE (skip this message
and continue), FOLDER (skip this folder and continue), REPO (skip this
account and continue), or CRITICAL (abort the application).

A first sample error in this series is thrown on DNS errors (or when offline),
Test it  by filling in a bogus host name or unplugging your computer.

I made it so that when we are in an autorefresh loop, that we abort the
account sync after 3 subsequent failure runs (of REPO severity). A
successfull sync resets the counter to 3. This behavior can be debated
and improved, but it lets intermittent network errors pass while still
bombing out on permanent errors.

The patches (on top of master):
effaf6c Add OfflineImapError class (adds the custom Exception, which is
        still unused)
6fa60a8 Throw OfflineImapError on DNS error (implements first Exception
        on DNS related errors)
d3ee1dc Remove duplicated code paths (cleanup patch that allowed me to
        only catch the Exception in one rather than 2 places)
f57b4bc Handle OfflineImapError of severity REPO and CRIT (abort account
        synchronization when we get an offlineimapError of this severity)
b7acd47 If we loop, exit the account synchronization after 3 failed attempts

Compare the old and the new output:
-----------------
OLD
-----------------
 ***** Processing account sspaeth.de
 Copying folder structure from IMAP to Maildir
 Establishing connection to sub3.mail.dreamhost.com:993.
 WARNING: Error occured attempting to sync account sspaeth.de: Traceback (most recent call last):
  File "/home/spaetz/src/offlineimap/offlineimap/accounts.py", line 191, in syncrunner
    self.sync(siglistener)
  File "/home/spaetz/src/offlineimap/offlineimap/accounts.py", line 246, in sync
    remoterepos.syncfoldersto(localrepos, [statusrepos])
  File "/home/spaetz/src/offlineimap/offlineimap/repository/Base.py", line 121, in syncfoldersto
    srcfolders = src.getfolders()
  File "/home/spaetz/src/offlineimap/offlineimap/repository/IMAP.py", line 242, in getfolders
    imapobj = self.imapserver.acquireconnection()
  File "/home/spaetz/src/offlineimap/offlineimap/imapserver.py", line 207, in acquireconnection
    cacertfile = self.sslcacertfile)
  File "/home/spaetz/src/offlineimap/offlineimap/imaplibutil.py", line 141, in __init__
    IMAP4_SSL.__init__(self, *args, **kwargs)
  File "/home/spaetz/src/offlineimap/offlineimap/imaplib2.py", line 1871, in __init__
    IMAP4.__init__(self, host, port, debug, debug_file, identifier, timeout)
  File "/home/spaetz/src/offlineimap/offlineimap/imaplib2.py", line 309, in __init__
    self.open(host, port)
  File "/home/spaetz/src/offlineimap/offlineimap/imaplibutil.py", line 157, in open
    socket.SOCK_STREAM)
gaierror: [Errno -2] Name or service not known
 ***** Finished processing account sspaeth.de



-----------------
NEW
-----------------

***** Processing account sspaeth.de
Copying folder structure from IMAP to Maildir
Establishing connection to xsub3.mail.dreamhost.com:993.
WARNING: Could not resolve name 'XXmail.sspaeth.de' for repository 'Remote'. Make sure you have configured the server name correctly and that you are online.
***** Finished processing account sspaeth.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/offlineimap-project/attachments/20110504/ff408927/attachment.sig>


More information about the OfflineIMAP-project mailing list