From 1b7c942b5c2a3dcd5df1e9b8b4d9640ab4dd37f0 Mon Sep 17 00:00:00 2001 From: Jared O'Connell <46976761+jaredoconnell@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:08:48 -0500 Subject: [PATCH] Fix error handling when aborting a workflow (#239) --- 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) } }