From 1256372d36384b48242faf0c7ad15ad1f2a3dc31 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Philipp=20H=C3=B6rist?= <philipp@hoerist.com>
Date: Sun, 10 Feb 2019 00:39:10 +0100
Subject: [PATCH] Handle nbxmpp error results

---
 gajim/common/modules/blocking.py    | 5 +++--
 gajim/common/modules/bookmarks.py   | 5 +++++
 gajim/common/modules/user_avatar.py | 5 +++++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/gajim/common/modules/blocking.py b/gajim/common/modules/blocking.py
index 5438a08198..7f5f7556e7 100644
--- a/gajim/common/modules/blocking.py
+++ b/gajim/common/modules/blocking.py
@@ -17,6 +17,7 @@
 import logging
 
 import nbxmpp
+from nbxmpp.util import is_error_result
 
 from gajim.common import app
 from gajim.common.nec import NetworkEvent
@@ -62,8 +63,8 @@ class Blocking(BaseModule):
         log.info('Discovered blocking: %s', from_)
 
     def _blocking_list_received(self, result):
-        if result.is_error:
-            log.info('Error: %s', result.error)
+        if is_error_result(result):
+            log.info('Error: %s', result)
             return
 
         self.blocked = result.blocking_list
diff --git a/gajim/common/modules/bookmarks.py b/gajim/common/modules/bookmarks.py
index 4ba7041021..c1197617f1 100644
--- a/gajim/common/modules/bookmarks.py
+++ b/gajim/common/modules/bookmarks.py
@@ -22,6 +22,7 @@ import logging
 import copy
 
 import nbxmpp
+from nbxmpp.util import is_error_result
 from nbxmpp.structs import BookmarkData
 from nbxmpp.const import BookmarkStoreType
 from gi.repository import GLib
@@ -161,6 +162,10 @@ class Bookmarks(BaseModule):
             type_, callback=self._bookmarks_received)
 
     def _bookmarks_received(self, bookmarks):
+        if is_error_result(bookmarks):
+            log.info('Error: %s', bookmarks)
+            bookmarks = []
+
         self._request_in_progress = False
         self._bookmarks = bookmarks
         self.auto_join_bookmarks()
diff --git a/gajim/common/modules/user_avatar.py b/gajim/common/modules/user_avatar.py
index d4246e75e1..5a3787d7ca 100644
--- a/gajim/common/modules/user_avatar.py
+++ b/gajim/common/modules/user_avatar.py
@@ -17,6 +17,7 @@
 import logging
 
 import nbxmpp
+from nbxmpp.util import is_error_result
 
 from gajim.common import app
 from gajim.common.modules.base import BaseModule
@@ -65,6 +66,10 @@ class UserAvatar(BaseModule):
                 jid, data.id, callback=self._avatar_received)
 
     def _avatar_received(self, result):
+        if is_error_result(result):
+            log.info('Error: %s', result)
+            return
+
         log.info('Received Avatar: %s %s', result.jid, result.sha)
         app.interface.save_avatar(result.data)
 
-- 
GitLab