Skip to content

Commit 6720332

Browse files
authored
Improve error logging
1 parent dc590d4 commit 6720332

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

internal/workflow/executor.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func (e *executor) handleActivityCompleted(event history.Event, a *history.Activ
289289

290290
err := f(a.Result, nil)
291291
if err != nil {
292-
return fmt.Errorf("setting result: %w", err)
292+
return fmt.Errorf("setting activity completed result: %w", err)
293293
}
294294

295295
return e.workflow.Continue(e.workflowCtx)
@@ -302,7 +302,7 @@ func (e *executor) handleActivityFailed(event history.Event, a *history.Activity
302302
}
303303

304304
if err := f(nil, errors.New(a.Reason)); err != nil {
305-
return fmt.Errorf("setting result: %w", err)
305+
return fmt.Errorf("setting activity failed result: %w", err)
306306
}
307307

308308
return e.workflow.Continue(e.workflowCtx)
@@ -329,7 +329,7 @@ func (e *executor) handleTimerFired(event history.Event, a *history.TimerFiredAt
329329
}
330330

331331
if err := f(nil, nil); err != nil {
332-
return fmt.Errorf("setting result: %w", err)
332+
return fmt.Errorf("setting timer fired result: %w", err)
333333
}
334334

335335
return e.workflow.Continue(e.workflowCtx)
@@ -343,7 +343,7 @@ func (e *executor) handleTimerCanceled(event history.Event, a *history.TimerCanc
343343
}
344344

345345
if err := f(nil, sync.Canceled); err != nil {
346-
return fmt.Errorf("setting result: %w", err)
346+
return fmt.Errorf("setting timer canceled result: %w", err)
347347
}
348348

349349
return e.workflow.Continue(e.workflowCtx)
@@ -392,7 +392,7 @@ func (e *executor) handleSubWorkflowFailed(event history.Event, a *history.SubWo
392392
}
393393

394394
if err := f(nil, errors.New(a.Error)); err != nil {
395-
return fmt.Errorf("setting result: %w", err)
395+
return fmt.Errorf("setting sub workflow failed result: %w", err)
396396
}
397397

398398
return e.workflow.Continue(e.workflowCtx)
@@ -405,7 +405,7 @@ func (e *executor) handleSubWorkflowCompleted(event history.Event, a *history.Su
405405
}
406406

407407
if err := f(a.Result, nil); err != nil {
408-
return fmt.Errorf("setting result: %w", err)
408+
return fmt.Errorf("setting sub workflow completed result: %w", err)
409409
}
410410

411411
return e.workflow.Continue(e.workflowCtx)
@@ -424,7 +424,9 @@ func (e *executor) handleSideEffectResult(event history.Event, a *history.SideEf
424424
return errors.New("no pending future found for side effect result event")
425425
}
426426

427-
f(a.Result, nil)
427+
if err := f(a.Result, nil); err != nil {
428+
return fmt.Errorf("setting side effect result result: %w", err)
429+
}
428430

429431
return e.workflow.Continue(e.workflowCtx)
430432
}
@@ -577,7 +579,7 @@ func (e *executor) processCommands(ctx context.Context, t *task.Workflow) (bool,
577579
&history.SubWorkflowFailedAttributes{
578580
Error: a.Error,
579581
},
580-
// Ensure the message gets sent back to the parent workflow with the right eventID
582+
// Ensure the message gets sent back to the parent workflow with the right schedule event ID
581583
history.ScheduleEventID(instance.ParentEventID),
582584
)
583585
} else {
@@ -586,7 +588,7 @@ func (e *executor) processCommands(ctx context.Context, t *task.Workflow) (bool,
586588
&history.SubWorkflowCompletedAttributes{
587589
Result: a.Result,
588590
},
589-
// Ensure the message gets sent back to the parent workflow with the right eventID
591+
// Ensure the message gets sent back to the parent workflow with the right schedule event ID
590592
history.ScheduleEventID(instance.ParentEventID),
591593
)
592594
}

0 commit comments

Comments
 (0)