Adding proper exception information
This commit is contained in:
parent
340ae68eed
commit
817333f26e
|
@ -78,7 +78,7 @@ class Approval(object):
|
|||
instance.approver = LdapService.user_info(model.approver_uid)
|
||||
instance.primary_investigator = LdapService.user_info(model.study.primary_investigator_id)
|
||||
except ApiError as ae:
|
||||
app.logger.error("Ldap lookup failed for approval record %i" % model.id)
|
||||
app.logger.error(f'Ldap lookup failed for approval record {model.id}', exc_info=True)
|
||||
|
||||
doc_dictionary = FileService.get_doc_dictionary()
|
||||
instance.associated_files = []
|
||||
|
|
|
@ -52,8 +52,7 @@ Email Subject ApprvlApprvr1 PIComputingID
|
|||
try:
|
||||
uid = task.workflow.script_engine.evaluate_expression(task, arg)
|
||||
except Exception as e:
|
||||
app.logger.error(f'Workflow engines could not parse {arg}')
|
||||
app.logger.error(str(e))
|
||||
app.logger.error(f'Workflow engines could not parse {arg}', exc_info=True)
|
||||
continue
|
||||
user_info = LdapService.user_info(uid)
|
||||
email = user_info.email_address
|
||||
|
|
|
@ -258,7 +258,7 @@ class ApprovalService(object):
|
|||
f'{approver_info.display_name} - ({approver_info.uid})'
|
||||
)
|
||||
if mail_result:
|
||||
app.logger.error(mail_result)
|
||||
app.logger.error(mail_result, exc_info=True)
|
||||
elif status == ApprovalStatus.DECLINED.value:
|
||||
ldap_service = LdapService()
|
||||
pi_user_info = ldap_service.user_info(db_approval.study.primary_investigator_id)
|
||||
|
@ -270,7 +270,7 @@ class ApprovalService(object):
|
|||
f'{approver_info.display_name} - ({approver_info.uid})'
|
||||
)
|
||||
if mail_result:
|
||||
app.logger.error(mail_result)
|
||||
app.logger.error(mail_result, exc_info=True)
|
||||
first_approval = ApprovalModel().query.filter_by(
|
||||
study_id=db_approval.study_id, workflow_id=db_approval.workflow_id,
|
||||
status=ApprovalStatus.APPROVED.value, version=db_approval.version).first()
|
||||
|
@ -286,7 +286,7 @@ class ApprovalService(object):
|
|||
f'{approver_info.display_name} - ({approver_info.uid})'
|
||||
)
|
||||
if mail_result:
|
||||
app.logger.error(mail_result)
|
||||
app.logger.error(mail_result, exc_info=True)
|
||||
# TODO: Log update action by approver_uid - maybe ?
|
||||
return db_approval
|
||||
|
||||
|
@ -357,7 +357,7 @@ class ApprovalService(object):
|
|||
f'{approver_info.display_name} - ({approver_info.uid})'
|
||||
)
|
||||
if mail_result:
|
||||
app.logger.error(mail_result)
|
||||
app.logger.error(mail_result, exc_info=True)
|
||||
# send rrp approval request for first approver
|
||||
# enhance the second part in case it bombs
|
||||
approver_email = [approver_info.email_address] if approver_info.email_address else app.config['FALLBACK_EMAILS']
|
||||
|
@ -367,7 +367,7 @@ class ApprovalService(object):
|
|||
f'{pi_user_info.display_name} - ({pi_user_info.uid})'
|
||||
)
|
||||
if mail_result:
|
||||
app.logger.error(mail_result)
|
||||
app.logger.error(mail_result, exc_info=True)
|
||||
|
||||
@staticmethod
|
||||
def _create_approval_files(workflow_data_files, approval):
|
||||
|
|
|
@ -36,6 +36,7 @@ class EmailService(object):
|
|||
|
||||
mail.send(msg)
|
||||
except Exception as e:
|
||||
app.logger.error('An exception happened in EmailService', exc_info=True)
|
||||
app.logger.error(str(e))
|
||||
|
||||
db.session.add(email_model)
|
||||
|
|
|
@ -137,7 +137,7 @@ class StudyService(object):
|
|||
try:
|
||||
pb_docs = ProtocolBuilderService.get_required_docs(study_id=study_id)
|
||||
except requests.exceptions.ConnectionError as ce:
|
||||
app.logger.error("Failed to connect to the Protocol Builder - %s" % str(ce))
|
||||
app.logger.error(f'Failed to connect to the Protocol Builder - {str(ce)}', exc_info=True)
|
||||
pb_docs = []
|
||||
else:
|
||||
pb_docs = []
|
||||
|
|
|
@ -255,9 +255,12 @@ class WorkflowService(object):
|
|||
if latest_event.form_data is not None:
|
||||
return latest_event.form_data
|
||||
else:
|
||||
app.logger.error("missing_form_data", "We have lost data for workflow %i, "
|
||||
"task %s, it is not in the task event model, "
|
||||
"and it should be." % (workflow_id, spiff_task.task_spec.name))
|
||||
missing_form_error = (
|
||||
f'We have lost data for workflow {workflow_id}, '
|
||||
f'task {spiff_task.task_spec.name}, it is not in the task event model, '
|
||||
f'and it should be.'
|
||||
)
|
||||
app.logger.error("missing_form_data", missing_form_error, exc_info=True)
|
||||
return {}
|
||||
else:
|
||||
return {}
|
||||
|
@ -347,7 +350,7 @@ class WorkflowService(object):
|
|||
template = Template(v)
|
||||
props[k] = template.render(**spiff_task.data)
|
||||
except jinja2.exceptions.TemplateError as ue:
|
||||
app.logger.error("Failed to process task property %s " % str(ue))
|
||||
app.logger.error(f'Failed to process task property {str(ue)}', exc_info=True)
|
||||
return props
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -168,8 +168,6 @@ class TestStudyApi(BaseTest):
|
|||
num_open = 0
|
||||
|
||||
for study in json_data:
|
||||
if study['protocol_builder_status'] == 'INCOMPLETE': # One study in user_studies.json is not q_complete
|
||||
num_incomplete += 1
|
||||
if study['protocol_builder_status'] == 'ABANDONED': # One study does not exist in user_studies.json
|
||||
num_abandoned += 1
|
||||
if study['protocol_builder_status'] == 'ACTIVE': # One study is marked complete without HSR Number
|
||||
|
@ -182,8 +180,7 @@ class TestStudyApi(BaseTest):
|
|||
self.assertGreater(num_db_studies_after, num_db_studies_before)
|
||||
self.assertEqual(num_abandoned, 1)
|
||||
self.assertEqual(num_open, 1)
|
||||
self.assertEqual(num_active, 1)
|
||||
self.assertEqual(num_incomplete, 1)
|
||||
self.assertEqual(num_active, 2)
|
||||
self.assertEqual(len(json_data), num_db_studies_after)
|
||||
self.assertEqual(num_open + num_active + num_incomplete + num_abandoned, num_db_studies_after)
|
||||
|
||||
|
|
Loading…
Reference in New Issue