changeset 1080:2c2b8c08e6c9

pages (forums): log a warning and use an empty list when forums are not available
author Goffi <goffi@goffi.org>
date Tue, 27 Mar 2018 08:36:37 +0200
parents 3af28f84ce91
children ed67265205c4
files src/pages/forums/list/page_meta.py
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/pages/forums/list/page_meta.py	Tue Mar 27 08:35:37 2018 +0200
+++ b/src/pages/forums/list/page_meta.py	Tue Mar 27 08:36:37 2018 +0200
@@ -4,6 +4,7 @@
 from libervia.server.constants import Const as C
 from twisted.internet import defer
 from sat.core.log import getLogger
+from sat.core.i18n import _
 from sat.tools.common import uri as xmpp_uri
 log = getLogger('pages/forum')
 import json
@@ -40,8 +41,13 @@
     service, node, key = data[u'service'], data[u'node'], data[u'forum_key']
     profile = self.getProfile(request) or C.SERVICE_PROFILE
 
-    forums_raw = yield self.host.bridgeCall('forumsGet', service.full() if service else u'', node, key, profile)
-    forums = json.loads(forums_raw)
+    try:
+        forums_raw = yield self.host.bridgeCall('forumsGet', service.full() if service else u'', node, key, profile)
+    except Exception as e:
+        log.warning(_(u"Can't retrieve forums: {msg}").format(msg=e))
+        forums = []
+    else:
+        forums = json.loads(forums_raw)
     getLinks(self, forums)
 
     template_data[u'forums'] = forums