changeset 3023:1f74cd0f22c3

plugin XEP-0313: log issues in addToHistory instead of raising error
author Goffi <goffi@goffi.org>
date Wed, 24 Jul 2019 07:51:48 +0200
parents 03fe31effa7f
children c2e7bb251e3e
files sat/plugins/plugin_xep_0313.py
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0313.py	Wed Jul 24 07:51:07 2019 +0200
+++ b/sat/plugins/plugin_xep_0313.py	Wed Jul 24 07:51:48 2019 +0200
@@ -135,7 +135,15 @@
                         continue
                     # adding message to history
                     mess_data = client.messageProt.parseMessage(fwd_message_elt)
-                    yield client.messageProt.addToHistory(mess_data)
+                    try:
+                        yield client.messageProt.addToHistory(mess_data)
+                    except exceptions.CancelError as e:
+                        log.warning(
+                            u"message has not been added to history: {e}".format(e=e))
+                    except Exception as e:
+                        log.error(
+                            u"can't add message to history: {e}\n{xml}"
+                            .format(e=e, xml=mess_elt.toXml()))
 
         if not count:
             log.info(_(u"We have received no message while offline"))