summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/mail
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2017-04-24 01:06:24 +0200
committerKali Kaneko (leap communications) <kali@leap.se>2017-04-27 19:33:24 +0200
commit47b30db62f339f5143298b3bcb6e2709b5a99926 (patch)
treef7385a83321dc121a2fe03017eb52a1aaddcbcd9 /src/leap/bitmask/mail
parentca71c03d12adfa26bf19a18c60245bdf6494afdc (diff)
[bug] catch failures with newer twisted logger
the migration from the stdlib python's logger to twisted logger is unable to format properly the failures unless the call is adapted - Related: #8849
Diffstat (limited to 'src/leap/bitmask/mail')
-rw-r--r--src/leap/bitmask/mail/adaptors/soledad.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/leap/bitmask/mail/adaptors/soledad.py b/src/leap/bitmask/mail/adaptors/soledad.py
index cd6c42f..6a057d6 100644
--- a/src/leap/bitmask/mail/adaptors/soledad.py
+++ b/src/leap/bitmask/mail/adaptors/soledad.py
@@ -462,6 +462,7 @@ class MessageWrapper(object):
# documents at the same time maybe, and defend against concurrent updates?
implements(IMessageWrapper)
+ log = Logger()
def __init__(self, mdoc, fdoc, hdoc, cdocs=None, is_copy=False):
"""
@@ -564,11 +565,14 @@ class MessageWrapper(object):
# TODO check that the doc_ids in the mdoc are coherent
self.d = []
- mdoc_created = self.mdoc.create(store, is_copy=self._is_copy)
- fdoc_created = self.fdoc.create(store, is_copy=self._is_copy)
-
- mdoc_created.addErrback(logger.error)
- fdoc_created.addErrback(logger.error)
+ try:
+ mdoc_created = self.mdoc.create(store, is_copy=self._is_copy)
+ except Exception:
+ self.log.failure("Error creating mdoc")
+ try:
+ fdoc_created = self.fdoc.create(store, is_copy=self._is_copy)
+ except Exception:
+ self.log.failure("Error creating fdoc")
self.d.append(mdoc_created)
self.d.append(fdoc_created)
@@ -590,7 +594,6 @@ class MessageWrapper(object):
self.all_inserted_d = defer.gatherResults(self.d, consumeErrors=True)
self.all_inserted_d.addCallback(log_all_inserted)
self.all_inserted_d.addCallback(unblock_pending_insert)
- self.all_inserted_d.addErrback(logger.error)
if notify_just_mdoc:
return mdoc_created
@@ -639,7 +642,6 @@ class MessageWrapper(object):
d = new_wrapper.create(store)
d.addCallback(lambda result: new_wrapper)
- d.addErrback(logger.error)
return d
def set_mbox_uuid(self, mbox_uuid):
@@ -950,7 +952,6 @@ class SoledadMailAdaptor(SoledadIndexMixin):
logger.debug(
"BUG: Error while retrieving part docs for mdoc id %s" %
mdoc_id)
- logger.error(failure)
logger.debug("BUG (please report above info) ---------------")
return []
@@ -1041,8 +1042,6 @@ class SoledadMailAdaptor(SoledadIndexMixin):
"""
Delete all messages flagged as deleted.
"""
- def err(failure):
- logger.error(failure)
def delete_fdoc_and_mdoc_flagged(fdocs):
# low level here, not using the wrappers...
@@ -1064,7 +1063,6 @@ class SoledadMailAdaptor(SoledadIndexMixin):
d = store.get_docs(mdoc_ids)
d.addCallback(delete_all_docs, fdocs)
- d.addErrback(err)
return d
type_ = FlagsDocWrapper.model.type_
@@ -1072,7 +1070,7 @@ class SoledadMailAdaptor(SoledadIndexMixin):
deleted_index = indexes.TYPE_MBOX_DEL_IDX
d = store.get_from_index(deleted_index, type_, uuid, "1")
- d.addCallbacks(delete_fdoc_and_mdoc_flagged, err)
+ d.addCallback(delete_fdoc_and_mdoc_flagged)
return d
# count messages
@@ -1178,7 +1176,7 @@ class SoledadMailAdaptor(SoledadIndexMixin):
return MailboxWrapper.get_all(store)
def _errback(self, failure):
- logger.error(failure)
+ logger.failure()
def _split_into_parts(raw):