2021-02-04 16:23:05 +00:00
|
|
|
# known_errors
|
|
|
|
# key - something we can search for in an error message.
|
|
|
|
# both_message - human readable message return to the user if error occurs in both
|
|
|
|
# required_message - human readable message return to the user if error only occurs in required
|
|
|
|
# all_message -human readable message return to the user if error only occurs in all
|
|
|
|
#
|
|
|
|
known_errors = [{'key': 'Error is Non-default exclusive outgoing sequence flow without condition',
|
2021-02-10 17:28:59 +00:00
|
|
|
'message': 'Missing condition', 'hint': 'Add a Condition Type to your gateway path.'}]
|
2021-02-04 16:23:05 +00:00
|
|
|
generic_message = """Workflow validation failed. For more information about the error, see below."""
|
|
|
|
|
|
|
|
class ValidationErrorService(object):
|
|
|
|
|
|
|
|
"""Validation Error Service interprets messages return from api.workflow.validate_workflow_specification
|
|
|
|
Validation is run twice,
|
|
|
|
once where we try to fill in all form fields
|
|
|
|
and a second time where we only fill in the required fields.
|
|
|
|
|
|
|
|
We get a list that contains possible errors from the validation."""
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def interpret_validation_errors(errors):
|
|
|
|
if len(errors) == 0:
|
2021-02-10 17:28:59 +00:00
|
|
|
return ()
|
2021-02-04 16:23:05 +00:00
|
|
|
hint = ''
|
2021-02-10 17:28:59 +00:00
|
|
|
|
2021-02-04 16:23:05 +00:00
|
|
|
for known_error in known_errors:
|
2021-02-10 17:28:59 +00:00
|
|
|
if known_error['key'] in errors['all'].message:
|
2021-02-04 16:23:05 +00:00
|
|
|
|
2021-02-10 17:28:59 +00:00
|
|
|
# in both error all and error required
|
|
|
|
if known_error['key'] in errors['required'].message:
|
2021-02-04 16:23:05 +00:00
|
|
|
if 'both_hint' in known_error.keys():
|
|
|
|
hint = known_error['both_hint']
|
|
|
|
if 'both_message' in known_error.keys():
|
|
|
|
message = known_error['both_message']
|
|
|
|
|
2021-02-10 17:28:59 +00:00
|
|
|
# just in error all
|
2021-02-04 16:23:05 +00:00
|
|
|
else:
|
|
|
|
pass
|
|
|
|
|
2021-02-10 17:28:59 +00:00
|
|
|
# just in error required
|
|
|
|
if known_error['key'] in errors['required'].message:
|
2021-02-04 16:23:05 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
return errors
|