diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2012-08-21 20:11:37 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2012-08-21 20:28:58 +0100 |
commit | 3a93c09a3a48e7c90f929756e51c6577a1ae6a7a (patch) | |
tree | 26e7c2b3611b67071baebe33953b097d27ce23bd /alot/account.py | |
parent | ab720c6e595da04fa5619cabd8e86f7bc78a71a5 (diff) |
catch exceptions raised by account.store_mail
be more error concious when storing mails to a maildir
and propagate Maildir errors to error notifications in the UI.
cf issue #502
Diffstat (limited to 'alot/account.py')
-rw-r--r-- | alot/account.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/alot/account.py b/alot/account.py index 1686bff7..83126f4c 100644 --- a/alot/account.py +++ b/alot/account.py @@ -14,6 +14,10 @@ class SendingMailFailed(RuntimeError): pass +class StoreMailError(Exception): + pass + + class Account(object): """ Datastructure that represents an email account. It manages this account's @@ -79,6 +83,7 @@ class Account(object): :returns: absolute path of mail-file for Maildir or None if mail was successfully stored :rtype: str or None + :raises: StoreMailError """ if not isinstance(mbx, mailbox.Mailbox): logging.debug('Not a mailbox') @@ -93,10 +98,13 @@ class Account(object): logging.debug('no Maildir') msg = mailbox.Message(mail) - message_id = mbx.add(msg) - mbx.flush() - mbx.unlock() - logging.debug('got id : %s' % id) + try: + message_id = mbx.add(msg) + mbx.flush() + mbx.unlock() + logging.debug('got mailbox msg id : %s' % message_id) + except Exception as e: + raise StoreMailError(e) path = None # add new Maildir message to index and add tags |