Revert "wscall: do not notify or record applications errors (#20491)"
This reverts commit a1966769a3
, pushed by mistake
This commit is contained in:
parent
b94609fab5
commit
dc213dafca
|
@ -1236,11 +1236,6 @@ def test_webservice_waitpoint(pub):
|
|||
def test_webservice_call_error_handling(pub):
|
||||
pub.substitutions.feed(MockSubstitutionVariables())
|
||||
|
||||
notifications = []
|
||||
def notify_of_exception(exc_info, context):
|
||||
notifications.append((exc_info, context))
|
||||
pub.notify_of_exception = notify_of_exception
|
||||
|
||||
FormDef.wipe()
|
||||
formdef = FormDef()
|
||||
formdef.name = 'baz'
|
||||
|
@ -1258,12 +1253,8 @@ def test_webservice_call_error_handling(pub):
|
|||
item.action_on_4xx = ':pass'
|
||||
item.action_on_5xx = ':pass'
|
||||
item.action_on_network_errors = ':pass'
|
||||
item.record_errors = True
|
||||
with pytest.raises(AbortActionException):
|
||||
item.perform(formdata)
|
||||
# application errors are not notified and not recorded
|
||||
assert len(notifications) == 0
|
||||
assert formdata.evolution[-1].parts is None
|
||||
|
||||
item = WebserviceCallStatusItem()
|
||||
item.url = 'http://remote.example.net/json-errheader1'
|
||||
|
@ -1455,9 +1446,6 @@ def test_webservice_call_error_handling(pub):
|
|||
item.perform(formdata)
|
||||
formdata.workflow_data = None
|
||||
|
||||
# all previous errors are "normal" application errors, no traceback notification
|
||||
assert len(notifications) == 0
|
||||
|
||||
# xml instead of json is not a app_error
|
||||
item = WebserviceCallStatusItem()
|
||||
item.url = 'http://remote.example.net/xml'
|
||||
|
@ -1468,9 +1456,7 @@ def test_webservice_call_error_handling(pub):
|
|||
item.action_on_5xx = ':pass'
|
||||
item.action_on_network_errors = ':pass'
|
||||
item.action_on_bad_data = ':pass'
|
||||
notifications = []
|
||||
item.perform(formdata)
|
||||
assert len(notifications) == 1
|
||||
formdata.workflow_data = None
|
||||
|
||||
# connection error
|
||||
|
@ -1479,23 +1465,8 @@ def test_webservice_call_error_handling(pub):
|
|||
item.post = False
|
||||
item.record_errors = True
|
||||
item.action_on_network_errors = ':pass'
|
||||
notifications = []
|
||||
item.perform(formdata)
|
||||
assert formdata.evolution[-1].parts[-1].summary == 'ConnectionError: error\n'
|
||||
assert len(notifications) == 1
|
||||
|
||||
# connection error, without record or notify
|
||||
item = WebserviceCallStatusItem()
|
||||
item.url = 'http://remote.example.net/connection-error'
|
||||
item.post = False
|
||||
item.record_errors = False
|
||||
item.notify_on_errors = False
|
||||
item.action_on_network_errors = ':pass'
|
||||
notifications = []
|
||||
formdata.just_created() # reset evolution
|
||||
item.perform(formdata)
|
||||
assert len(notifications) == 0
|
||||
assert formdata.evolution[-1].parts is None
|
||||
|
||||
def test_webservice_call_store_in_backoffice_filefield(pub):
|
||||
wf = Workflow(name='wscall to backoffice file field')
|
||||
|
|
|
@ -246,12 +246,12 @@ class WebserviceCallStatusItem(WorkflowStatusItem):
|
|||
|
||||
if 'notify_on_errors' in parameters:
|
||||
form.add(CheckboxWidget, '%snotify_on_errors' % prefix,
|
||||
title=_('Notify on errors (except application errors)'),
|
||||
title=_('Notify on errors'),
|
||||
value=self.notify_on_errors)
|
||||
|
||||
if 'record_errors' in parameters:
|
||||
form.add(CheckboxWidget, '%srecord_errors' % prefix,
|
||||
title=_('Record errors in the log (except application errors)'),
|
||||
title=_('Record errors in the log'),
|
||||
value=self.record_errors)
|
||||
|
||||
def perform(self, formdata):
|
||||
|
@ -314,8 +314,7 @@ class WebserviceCallStatusItem(WorkflowStatusItem):
|
|||
formdata.store()
|
||||
|
||||
if app_error_code != 0:
|
||||
self.action_on_error(self.action_on_app_error, formdata, response, data=data,
|
||||
is_app_error=True)
|
||||
self.action_on_error(self.action_on_app_error, formdata, response, data=data)
|
||||
if (status // 100) == 4:
|
||||
self.action_on_error(self.action_on_4xx, formdata, response, data=data)
|
||||
if (status // 100) == 5:
|
||||
|
@ -358,10 +357,8 @@ class WebserviceCallStatusItem(WorkflowStatusItem):
|
|||
content_type,
|
||||
data)
|
||||
|
||||
def action_on_error(self, action, formdata, response=None, data=None, exc_info=None,
|
||||
is_app_error=False):
|
||||
if action in (':pass', ':stop') and not is_app_error and (
|
||||
self.notify_on_errors or self.record_errors):
|
||||
def action_on_error(self, action, formdata, response=None, data=None, exc_info=None):
|
||||
if action in (':pass', ':stop') and (self.notify_on_errors or self.record_errors):
|
||||
if exc_info:
|
||||
summary = traceback.format_exception_only(exc_info[0], exc_info[1])[-1]
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue