From bd269d8ade239dd42e6fd28870a182d74d59b66e Mon Sep 17 00:00:00 2001 From: Jared O'Connell Date: Mon, 16 Dec 2024 11:52:08 -0500 Subject: [PATCH] Fix error handling when aborting a workflow --- workflow/workflow.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/workflow/workflow.go b/workflow/workflow.go index 57f4922..fc9f333 100644 --- a/workflow/workflow.go +++ b/workflow/workflow.go @@ -253,7 +253,13 @@ func (e *executableWorkflow) Execute(ctx context.Context, serializedInput any) ( return "", nil, lastErrors case <-timedContext.Done(): lastErrors := l.handleErrors() - return "", nil, fmt.Errorf("workflow execution aborted (%w) (%s)", ctx.Err(), lastErrors.Error()) + var errMsg string + if lastErrors == nil { + errMsg = "" + } else { + errMsg = lastErrors.Error() + } + return "", nil, fmt.Errorf("workflow execution aborted (%w) (%s)", ctx.Err(), errMsg) } }