changeset 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 ddc1e704bc41
children 92ca86e417e3
files libervia/server/pages.py
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
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)