Skip to content

Commit

Permalink
Print execptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Hossain Mahmud committed Oct 27, 2023
1 parent c4939d7 commit a99e6a9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions prefect_aws/ecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,13 +810,14 @@ def _create_task_and_wait_for_start(
task_definition_arn=task_definition_arn,
)
self.logger.info(f"{self._log_prefix}: Creating task run...")
self.logger.debug("Task run payload\n" + yaml.dump(task_run))
self.logger.info("Task run payload\n" + yaml.dump(task_run))

try:
task = self._run_task(ecs_client, task_run)
task_arn = task["taskArn"]
cluster_arn = task["clusterArn"]
except Exception as exc:
self.logger.info(f"EcsTaskException: {exc}")
self._report_task_run_creation_failure(task_run, exc)

# Raises an exception if the task does not start
Expand Down Expand Up @@ -1073,8 +1074,15 @@ def _wait_for_task_start(
if task["lastStatus"] == "STOPPED":
code = task.get("stopCode")
reason = task.get("stoppedReason")
# Generate a dynamic exception type from the AWS name
raise type(code, (RuntimeError,), {})(reason)

containers = task["containers"]
exit_codes = " ".join([container.get("exitCode", "?exitCode?") for container in containers])
try:
# Generate a dynamic exception type from the AWS name
raise type(code, (RuntimeError,), {})(f"{reason=} {exit_codes=}")
except Exception as exc:
self.logger.info(f"EcsTaskException: {exc}")
raise

return task

Expand Down

0 comments on commit a99e6a9

Please sign in to comment.