minor cleanup of error codes.
This commit is contained in:
parent
3e1d492bb1
commit
e102214809
|
@ -122,7 +122,7 @@ def get_file_info(file_id):
|
|||
|
||||
def update_file_info(file_id, body):
|
||||
if file_id is None:
|
||||
raise ApiError('unknown_file', 'Please provide a valid File ID.')
|
||||
raise ApiError('no_such_file', 'Please provide a valid File ID.')
|
||||
|
||||
file_model = session.query(FileModel).filter_by(id=file_id).first()
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ def update_study(study_id, body):
|
|||
def get_study(study_id):
|
||||
study = StudyService.get_study(study_id)
|
||||
if (study is None):
|
||||
raise ApiError("Study not found", status_code=404)
|
||||
raise ApiError("unknown_study", 'The study "' + study_id + '" is not recognized.', status_code=404)
|
||||
return StudySchema().dump(study)
|
||||
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@ def render_markdown(data, template):
|
|||
data = json.loads(data)
|
||||
return template.render(**data)
|
||||
except UndefinedError as ue:
|
||||
raise ApiError(code="undefined field", message=ue.message)
|
||||
raise ApiError(code="undefined_field", message=ue.message)
|
||||
except Exception as e:
|
||||
raise ApiError(code="invalid", message=str(e))
|
||||
raise ApiError(code="invalid_render", message=str(e))
|
||||
|
||||
|
||||
def render_docx():
|
||||
|
@ -42,9 +42,9 @@ def render_docx():
|
|||
cache_timeout=-1 # Don't cache these files on the browser.
|
||||
)
|
||||
except ValueError as e:
|
||||
raise ApiError(code="invalid", message=str(e))
|
||||
raise ApiError(code="undefined_field", message=str(e))
|
||||
except Exception as e:
|
||||
raise ApiError(code="invalid", message=str(e))
|
||||
raise ApiError(code="invalid_render", message=str(e))
|
||||
|
||||
|
||||
def list_scripts():
|
||||
|
|
|
@ -274,7 +274,7 @@ class FileService(object):
|
|||
workflow_spec_model = FileService.find_spec_model_in_db(workflow)
|
||||
|
||||
if workflow_spec_model is None:
|
||||
raise ApiError(code="workflow_model_error",
|
||||
raise ApiError(code="unknown_workflow",
|
||||
message="Something is wrong. I can't find the workflow you are using.")
|
||||
|
||||
file_data_model = session.query(FileDataModel) \
|
||||
|
|
|
@ -103,7 +103,7 @@ class LookupService(object):
|
|||
workflow_id=workflow_model.id,
|
||||
name=file_name)
|
||||
if len(latest_files) < 1:
|
||||
raise ApiError("missing_file", "Unable to locate the lookup data file '%s'" % file_name)
|
||||
raise ApiError("invalid_enum", "Unable to locate the lookup data file '%s'" % file_name)
|
||||
else:
|
||||
data_model = latest_files[0]
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class ProtocolBuilderService(object):
|
|||
def get_studies(user_id) -> {}:
|
||||
ProtocolBuilderService.__enabled_or_raise()
|
||||
if not isinstance(user_id, str):
|
||||
raise ApiError("invalid_user_id", "This user id is invalid: " + str(user_id))
|
||||
raise ApiError("protocol_builder_error", "This user id is invalid: " + str(user_id))
|
||||
response = requests.get(ProtocolBuilderService.STUDY_URL % user_id)
|
||||
if response.ok and response.text:
|
||||
pb_studies = ProtocolBuilderStudySchema(many=True).loads(response.text)
|
||||
|
|
|
@ -319,9 +319,9 @@ class StudyService(object):
|
|||
try:
|
||||
StudyService._create_workflow_model(study_model, workflow_spec)
|
||||
except WorkflowTaskExecException as wtee:
|
||||
errors.append(ApiError.from_task("workflow_execution_exception", str(wtee), wtee.task))
|
||||
errors.append(ApiError.from_task("workflow_startup_exception", str(wtee), wtee.task))
|
||||
except WorkflowException as we:
|
||||
errors.append(ApiError.from_task_spec("workflow_execution_exception", str(we), we.sender))
|
||||
errors.append(ApiError.from_task_spec("workflow_startup_exception", str(we), we.sender))
|
||||
return errors
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -82,7 +82,7 @@ class WorkflowService(object):
|
|||
processor = WorkflowProcessor(workflow_model, validate_only=True)
|
||||
except WorkflowException as we:
|
||||
WorkflowService.delete_test_data()
|
||||
raise ApiError.from_workflow_exception("workflow_execution_exception", str(we), we)
|
||||
raise ApiError.from_workflow_exception("workflow_validation_exception", str(we), we)
|
||||
|
||||
while not processor.bpmn_workflow.is_completed():
|
||||
try:
|
||||
|
@ -96,7 +96,7 @@ class WorkflowService(object):
|
|||
task.complete()
|
||||
except WorkflowException as we:
|
||||
WorkflowService.delete_test_data()
|
||||
raise ApiError.from_workflow_exception("workflow_execution_exception", str(we), we)
|
||||
raise ApiError.from_workflow_exception("workflow_validation_exception", str(we), we)
|
||||
|
||||
WorkflowService.delete_test_data()
|
||||
return processor.bpmn_workflow.last_task.data
|
||||
|
@ -162,7 +162,7 @@ class WorkflowService(object):
|
|||
options.append({"id": d.value, "label": d.label})
|
||||
return random.choice(options)
|
||||
else:
|
||||
raise ApiError.from_task("invalid_autocomplete", "The settings for this auto complete field "
|
||||
raise ApiError.from_task("unknown_lookup_option", "The settings for this auto complete field "
|
||||
"are incorrect: %s " % field.id, task)
|
||||
elif field.type == "long":
|
||||
return random.randint(1, 1000)
|
||||
|
|
Loading…
Reference in New Issue