diff libervia/server/pages.py @ 1177:75c5e8d21c7d

server: catch "not-allowed" error from bridge and show the appropriate error page in this case
author Goffi <goffi@goffi.org>
date Fri, 03 May 2019 20:54:34 +0200
parents ab858db9dbee
children 7d6c0e5d5f34
line wrap: on
line diff
--- a/libervia/server/pages.py	Fri May 03 20:53:44 2019 +0200
+++ b/libervia/server/pages.py	Fri May 03 20:54:34 2019 +0200
@@ -27,6 +27,7 @@
 from sat.core import exceptions
 from sat.tools.common import date_utils
 from sat.core.log import getLogger
+from sat_frontends.bridge.bridge_frontend import BridgeException
 
 from libervia.server.constants import Const as C
 from libervia.server import session_iface
@@ -1241,6 +1242,9 @@
 
     def _internalError(self, failure_, request):
         """called if an error is not catched"""
+        if failure_.check(BridgeException) and failure_.value.condition == u'not-allowed':
+            log.warning(u"not allowed exception catched")
+            self.pageError(request, C.HTTP_FORBIDDEN)
         log.error(_(u"Uncatched error for HTTP request on {url}: {msg}")
             .format( url=request.URLPath(), msg=failure_))
         self.pageError(request, C.HTTP_INTERNAL_ERROR)