Still not in working order. Committing to work on another ticket.

This commit is contained in:
mike cullerton 2021-02-10 12:28:59 -05:00
parent fa34bee18a
commit 8a2a8b1443
2 changed files with 13 additions and 12 deletions

View File

@ -44,18 +44,18 @@ def get_workflow_specification(spec_id):
def validate_workflow_specification(spec_id):
errors = []
errors = {}
try:
WorkflowService.test_spec(spec_id)
except ApiError as ae:
# ae.message = "When populating all fields ... \n" + ae.message
errors.append(('all', ae))
errors['all'] = ae
try:
# Run the validation twice, the second time, just populate the required fields.
WorkflowService.test_spec(spec_id, required_only=True)
except ApiError as ae:
# ae.message = "When populating only required fields ... \n" + ae.message
errors.append(('required', ae))
errors['required'] = ae
interpreted_errors = ValidationErrorService.interpret_validation_errors(errors)
return ApiErrorSchema(many=True).dump(interpreted_errors)

View File

@ -5,7 +5,7 @@
# 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',
'message': 'Missing condition'}]
'message': 'Missing condition', 'hint': 'Add a Condition Type to your gateway path.'}]
generic_message = """Workflow validation failed. For more information about the error, see below."""
class ValidationErrorService(object):
@ -20,24 +20,25 @@ class ValidationErrorService(object):
@staticmethod
def interpret_validation_errors(errors):
if len(errors) == 0:
return errors
return ()
hint = ''
for known_error in known_errors:
if known_error['key'] in errors[0].message:
# in both error 0 and error 1
if known_error['key'] in errors[1].message:
for known_error in known_errors:
if known_error['key'] in errors['all'].message:
# in both error all and error required
if known_error['key'] in errors['required'].message:
if 'both_hint' in known_error.keys():
hint = known_error['both_hint']
if 'both_message' in known_error.keys():
message = known_error['both_message']
# just in error 0
# just in error all
else:
pass
# just in error 1
if known_error['key'] in errors[1].message:
# just in error required
if known_error['key'] in errors['required'].message:
pass
return errors