Update templates/workflow_template.py.j2
Some checks failed
CI Workflow / Testing the Flow (push) Failing after 12s
CI Workflow / Containerize the Flow (push) Has been skipped

This commit is contained in:
Admin User 2025-02-25 13:23:16 +00:00
parent 9533ce1f86
commit 9eab779b90

View File

@ -6,6 +6,7 @@ import json
import datetime import datetime
import re import re
import jmespath import jmespath
from temporalio.exceptions import ApplicationError
# Configure logging # Configure logging
logging.basicConfig(level=logging.INFO, logging.basicConfig(level=logging.INFO,
@ -111,7 +112,7 @@ class {{ workflow_class_name }}:
block_error = { block_error = {
"code": type(e).__name__, "code": type(e).__name__,
"description": str(e), "description": str(e),
"details": {} "details": {"cause": str(getattr(e, "cause", "No additional details"))}
} }
workflow_output["status"] = "failed" workflow_output["status"] = "failed"
# Collect block output # Collect block output
@ -141,10 +142,12 @@ class {{ workflow_class_name }}:
# Update workflow status to completed if not failed # Update workflow status to completed if not failed
if workflow_output["status"] != "failed": if workflow_output["status"] != "failed":
workflow_output["status"] = "completed" workflow_output["status"] = "completed"
else:
raise ApplicationError("Activity error occurred", type="ActivityError", non_retryable=True)
return workflow_output return workflow_output
except Exception as e: except Exception as e:
logger.error(f"Workflow failed with error: {e}") logger.error(f"Workflow failed with error: {e}")
workflow_output["status"] = "failed" workflow_output["status"] = "failed"
raise raise temporalio.exceptions.ApplicationError("Workflow failed",workflow_output,str(e),type="WorkflowError",non_retryable=True) from e