@@ -742,7 +742,7 @@ func (c *dbosContext) RunWorkflow(_ DBOSContext, fn WorkflowFunc, input any, opt
742742
743743 // Prevent spawning child workflows from within a step
744744 if isChildWorkflow && parentWorkflowState .isWithinStep {
745- return nil , newStepExecutionError (parentWorkflowState .workflowID , params .workflowName , "cannot spawn child workflow from within a step" )
745+ return nil , newStepExecutionError (parentWorkflowState .workflowID , params .workflowName , fmt . Errorf ( "cannot spawn child workflow from within a step" ) )
746746 }
747747
748748 if isChildWorkflow {
@@ -935,8 +935,7 @@ func (c *dbosContext) RunWorkflow(_ DBOSContext, fn WorkflowFunc, input any, opt
935935 result , err = fn (workflowCtx , input )
936936
937937 // Handle DBOS ID conflict errors by waiting workflow result
938- var dbosErr * DBOSError
939- if errors .As (err , & dbosErr ) && dbosErr .Code == ConflictingIDError {
938+ if errors .Is (err , & DBOSError {Code : ConflictingIDError }) {
940939 c .logger .Warn ("Workflow ID conflict detected. Waiting for existing workflow to complete" , "workflow_id" , workflowID )
941940 result , err = retryWithResult (c , func () (any , error ) {
942941 return c .systemDB .awaitWorkflowResult (uncancellableCtx , workflowID )
@@ -1098,11 +1097,11 @@ func WithMaxInterval(interval time.Duration) StepOption {
10981097// Under the hood, DBOS uses the provided context to manage durable execution.
10991098func RunAsStep [R any ](ctx DBOSContext , fn Step [R ], opts ... StepOption ) (R , error ) {
11001099 if ctx == nil {
1101- return * new (R ), newStepExecutionError ("" , "" , "ctx cannot be nil" )
1100+ return * new (R ), newStepExecutionError ("" , "" , fmt . Errorf ( "ctx cannot be nil" ) )
11021101 }
11031102
11041103 if fn == nil {
1105- return * new (R ), newStepExecutionError ("" , "" , "step function cannot be nil" )
1104+ return * new (R ), newStepExecutionError ("" , "" , fmt . Errorf ( "step function cannot be nil" ) )
11061105 }
11071106
11081107 // Register the output type for gob encoding
@@ -1144,12 +1143,12 @@ func (c *dbosContext) RunAsStep(_ DBOSContext, fn StepFunc, opts ...StepOption)
11441143 // Get workflow state from context
11451144 wfState , ok := c .Value (workflowStateKey ).(* workflowState )
11461145 if ! ok || wfState == nil {
1147- return nil , newStepExecutionError ("" , stepOpts .stepName , "workflow state not found in context: are you running this step within a workflow?" )
1146+ return nil , newStepExecutionError ("" , stepOpts .stepName , fmt . Errorf ( "workflow state not found in context: are you running this step within a workflow?" ) )
11481147 }
11491148
11501149 // This should not happen when called from the package-level RunAsStep
11511150 if fn == nil {
1152- return nil , newStepExecutionError (wfState .workflowID , stepOpts .stepName , "step function cannot be nil" )
1151+ return nil , newStepExecutionError (wfState .workflowID , stepOpts .stepName , fmt . Errorf ( "step function cannot be nil" ) )
11531152 }
11541153
11551154 // If within a step, just run the function directly
@@ -1176,7 +1175,7 @@ func (c *dbosContext) RunAsStep(_ DBOSContext, fn StepFunc, opts ...StepOption)
11761175 })
11771176 }, withRetrierLogger (c .logger ))
11781177 if err != nil {
1179- return nil , newStepExecutionError (stepState .workflowID , stepOpts .stepName , fmt .Sprintf ("checking operation execution: %v " , err ))
1178+ return nil , newStepExecutionError (stepState .workflowID , stepOpts .stepName , fmt .Errorf ("checking operation execution: %w " , err ))
11801179 }
11811180 if recordedOutput != nil {
11821181 return recordedOutput .output , recordedOutput .err
@@ -1205,7 +1204,7 @@ func (c *dbosContext) RunAsStep(_ DBOSContext, fn StepFunc, opts ...StepOption)
12051204 // Wait before retry
12061205 select {
12071206 case <- c .Done ():
1208- return nil , newStepExecutionError (stepState .workflowID , stepOpts .stepName , fmt .Sprintf ("context cancelled during retry: %v " , c .Err ()))
1207+ return nil , newStepExecutionError (stepState .workflowID , stepOpts .stepName , fmt .Errorf ("context cancelled during retry: %w " , c .Err ()))
12091208 case <- time .After (delay ):
12101209 // Continue to retry
12111210 }
@@ -1241,7 +1240,7 @@ func (c *dbosContext) RunAsStep(_ DBOSContext, fn StepFunc, opts ...StepOption)
12411240 return c .systemDB .recordOperationResult (uncancellableCtx , dbInput )
12421241 }, withRetrierLogger (c .logger ))
12431242 if recErr != nil {
1244- return nil , newStepExecutionError (stepState .workflowID , stepOpts .stepName , fmt . Sprintf ( "recording step outcome: %v" , recErr ) )
1243+ return nil , newStepExecutionError (stepState .workflowID , stepOpts .stepName , recErr )
12451244 }
12461245
12471246 return stepOutput , stepError
0 commit comments