Mercurial > libervia-web
comparison 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 |
comparison
equal
deleted
inserted
replaced
1176:ddc1e704bc41 | 1177:75c5e8d21c7d |
---|---|
25 | 25 |
26 from sat.core.i18n import _ | 26 from sat.core.i18n import _ |
27 from sat.core import exceptions | 27 from sat.core import exceptions |
28 from sat.tools.common import date_utils | 28 from sat.tools.common import date_utils |
29 from sat.core.log import getLogger | 29 from sat.core.log import getLogger |
30 from sat_frontends.bridge.bridge_frontend import BridgeException | |
30 | 31 |
31 from libervia.server.constants import Const as C | 32 from libervia.server.constants import Const as C |
32 from libervia.server import session_iface | 33 from libervia.server import session_iface |
33 from libervia.server.utils import quote, SubPage | 34 from libervia.server.utils import quote, SubPage |
34 | 35 |
1239 """don't raise error on CancelError""" | 1240 """don't raise error on CancelError""" |
1240 failure_.trap(exceptions.CancelError) | 1241 failure_.trap(exceptions.CancelError) |
1241 | 1242 |
1242 def _internalError(self, failure_, request): | 1243 def _internalError(self, failure_, request): |
1243 """called if an error is not catched""" | 1244 """called if an error is not catched""" |
1245 if failure_.check(BridgeException) and failure_.value.condition == u'not-allowed': | |
1246 log.warning(u"not allowed exception catched") | |
1247 self.pageError(request, C.HTTP_FORBIDDEN) | |
1244 log.error(_(u"Uncatched error for HTTP request on {url}: {msg}") | 1248 log.error(_(u"Uncatched error for HTTP request on {url}: {msg}") |
1245 .format( url=request.URLPath(), msg=failure_)) | 1249 .format( url=request.URLPath(), msg=failure_)) |
1246 self.pageError(request, C.HTTP_INTERNAL_ERROR) | 1250 self.pageError(request, C.HTTP_INTERNAL_ERROR) |
1247 | 1251 |
1248 def _on_data_post_redirect(self, ret, request): | 1252 def _on_data_post_redirect(self, ret, request): |