From 3a93c09a3a48e7c90f929756e51c6577a1ae6a7a Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Tue, 21 Aug 2012 20:11:37 +0100 Subject: 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 --- alot/account.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'alot/account.py') 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 -- cgit v1.2.3