File tree Expand file tree Collapse file tree 2 files changed +21
-7
lines changed
cadence/_internal/workflow
tests/integration_tests/workflow Expand file tree Collapse file tree 2 files changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -85,10 +85,7 @@ def process_decision(
8585 decisions .append (
8686 Decision (
8787 fail_workflow_execution_decision_attributes = FailWorkflowExecutionDecisionAttributes (
88- failure = Failure (
89- reason = str (e ),
90- details = traceback .format_exc ().encode ("utf-8" ),
91- )
88+ failure = _failure_from_workflow_failure (e )
9289 )
9390 )
9491 )
@@ -233,3 +230,16 @@ def _extract_workflow_input(
233230 return started_attrs .input
234231
235232 raise ValueError ("No WorkflowExecutionStarted event found in history" )
233+
234+
235+ def _failure_from_workflow_failure (e : WorkflowFailure ) -> Failure :
236+ cause = e .__cause__
237+
238+ stacktrace = "" .join (traceback .format_exception (cause ))
239+
240+ details = f"message: { str (cause )} \n stacktrace: { stacktrace } "
241+
242+ return Failure (
243+ reason = type (cause ).__name__ ,
244+ details = details .encode ("utf-8" ),
245+ )
Original file line number Diff line number Diff line change @@ -23,11 +23,15 @@ async def echo(self, message: str) -> str:
2323 return message
2424
2525
26+ class MockedFailure (Exception ):
27+ pass
28+
29+
2630@reg .workflow ()
2731class FailureWorkflow :
2832 @workflow .run
2933 async def failure (self , message : str ) -> str :
30- raise Exception ("mocked workflow failure" )
34+ raise MockedFailure ("mocked workflow failure" )
3135
3236
3337async def test_simple_workflow (helper : CadenceHelper ):
@@ -77,14 +81,14 @@ async def test_workflow_failure(helper: CadenceHelper):
7781 )
7882
7983 assert (
80- "Workflow failed: mocked workflow failure "
84+ "MockedFailure "
8185 == response .history .events [
8286 - 1
8387 ].workflow_execution_failed_event_attributes .failure .reason
8488 )
8589
8690 assert (
87- """raise Exception ("mocked workflow failure")"""
91+ """raise MockedFailure ("mocked workflow failure")"""
8892 in response .history .events [
8993 - 1
9094 ].workflow_execution_failed_event_attributes .failure .details .decode ()
You can’t perform that action at this time.
0 commit comments