From 0c227c30ee20b1af4518ecf56848b06572b4ed72 Mon Sep 17 00:00:00 2001 From: drebs Date: Sun, 12 Mar 2017 15:39:33 +0100 Subject: Fix logging of couchdb errors. Leap MX was previously wrapping soledad's couchdb-related exceptions messages in its own exception. The problem was that message attribute of those exceptions were actually empty, and so the information of the actual error was lost. This commit removes the wrapper exception and forwards whatever exception was received from soledad to the logging system. Signed-off-by: Ruben Pollan --- src/leap/mx/couchdbhelper.py | 9 +++------ src/leap/mx/tests/test_mail_receiver.py | 4 +--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/leap/mx/couchdbhelper.py b/src/leap/mx/couchdbhelper.py index 50275ca..eafc620 100644 --- a/src/leap/mx/couchdbhelper.py +++ b/src/leap/mx/couchdbhelper.py @@ -184,7 +184,8 @@ class ConnectedCouchDB(client.CouchDB): :return: A deferred which fires with the new revision identifier for the document if the Document object has being updated, or - which fails with CouchDBError if there was any error. + which fails with the correspondent exception if there was any + error. """ # TODO: that should be implemented with paisley url = self._mail_couch_url + "/user-%s" % (uuid,) @@ -192,8 +193,4 @@ class ConnectedCouchDB(client.CouchDB): db = CouchDatabase.open_database(url, create=False) return defer.succeed(db.put_doc(doc)) except Exception as e: - return defer.fail(CouchDBError(e.message)) - - -class CouchDBError(Exception): - pass + return defer.fail(e) diff --git a/src/leap/mx/tests/test_mail_receiver.py b/src/leap/mx/tests/test_mail_receiver.py index 33967ea..6b274cd 100644 --- a/src/leap/mx/tests/test_mail_receiver.py +++ b/src/leap/mx/tests/test_mail_receiver.py @@ -19,7 +19,6 @@ MailReceiver tests """ -import codecs import json import os import os.path @@ -31,7 +30,6 @@ from twisted.internet import defer, reactor from twisted.trial import unittest from leap.keymanager import openpgp -from leap.mx.couchdbhelper import CouchDBError from leap.mx.mail_receiver import MailReceiver @@ -91,7 +89,7 @@ class MailReceiverTestCase(unittest.TestCase): def put_doc_raise(*args): defer_called.callback(None) - return defer.fail(CouchDBError()) + return defer.fail(Exception()) self.users_cdb.put_doc = put_doc_raise _, path = self.addMail() -- cgit v1.2.3