Commit f26b9ea2 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Titouan Soulard

erp5_api_style: jIOWebSection jio calls catch NotFound Errors

parent bb89d035
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from AccessControl import Unauthorized from AccessControl import Unauthorized
from Acquisition import aq_inner from Acquisition import aq_inner
from OFS.Traversable import NotFound
from erp5.component.document.WebSection import WebSection from erp5.component.document.WebSection import WebSection
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from zLOG import LOG, INFO from zLOG import LOG, INFO
...@@ -47,13 +48,21 @@ def convertTojIOAPICall(function): ...@@ -47,13 +48,21 @@ def convertTojIOAPICall(function):
try: try:
retval = function(self, *args, **kwd) retval = function(self, *args, **kwd)
except Unauthorized, e: except Unauthorized, e:
LOG('SlapTool', INFO, 'Converting Unauthorized to Unauthorized error mesage in JSON,', LOG('jIOWebSection', INFO, 'Converting Unauthorized to Unauthorized error mesage in JSON,',
error=True) error=True)
return self.ERP5Site_logApiErrorAndReturn( return self.ERP5Site_logApiErrorAndReturn(
error_code="403", error_code="403",
error_message=str(e), error_message=str(e),
error_name="Unauthorized" error_name="Unauthorized"
) )
except NotFound, e:
LOG('jIOWebSection', INFO, 'Converting NotFound to NotFound error mesage in JSON,',
error=True)
return self.ERP5Site_logApiErrorAndReturn(
error_code="404",
error_message=str(e),
error_name="NotFound"
)
return '%s' % retval return '%s' % retval
wrapper.__doc__ = function.__doc__ wrapper.__doc__ = function.__doc__
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment