Closes #13334: Record error message on failed jobs (#14106)

This commit is contained in:
Jeremy Stretch
2023-10-31 08:34:57 -04:00
committed by GitHub
parent edc4a35296
commit 7323668dd0
9 changed files with 40 additions and 9 deletions
@@ -59,7 +59,7 @@ class Command(BaseCommand):
logger.error(f"Exception raised during script execution: {e}")
clear_webhooks.send(request)
job.data = ScriptOutputSerializer(script).data
job.terminate(status=JobStatusChoices.STATUS_ERRORED)
job.terminate(status=JobStatusChoices.STATUS_ERRORED, error=str(e))
logger.info(f"Script completed in {job.duration}")
+3 -3
View File
@@ -40,8 +40,8 @@ def run_report(job, *args, **kwargs):
try:
report.run(job)
except Exception:
job.terminate(status=JobStatusChoices.STATUS_ERRORED)
except Exception as e:
job.terminate(status=JobStatusChoices.STATUS_ERRORED, error=str(e))
logging.error(f"Error during execution of report {job.name}")
finally:
# Schedule the next job if an interval has been set
@@ -230,7 +230,7 @@ class Report(object):
stacktrace = traceback.format_exc()
self.log_failure(None, f"An exception occurred: {type(e).__name__}: {e} <pre>{stacktrace}</pre>")
logger.error(f"Exception raised during report execution: {e}")
job.terminate(status=JobStatusChoices.STATUS_ERRORED)
job.terminate(status=JobStatusChoices.STATUS_ERRORED, error=str(e))
# Perform any post-run tasks
self.post_run()
+1 -1
View File
@@ -519,7 +519,7 @@ def run_script(data, request, job, commit=True, **kwargs):
logger.error(f"Exception raised during script execution: {e}")
script.log_info("Database changes have been reverted due to error.")
job.data = ScriptOutputSerializer(script).data
job.terminate(status=JobStatusChoices.STATUS_ERRORED)
job.terminate(status=JobStatusChoices.STATUS_ERRORED, error=str(e))
clear_webhooks.send(request)
logger.info(f"Script completed in {job.duration}")