diff --git a/sdk-go/littlehorse/lh_errors.go b/sdk-go/littlehorse/lh_errors.go index 4dd9610a0..867bb4132 100644 --- a/sdk-go/littlehorse/lh_errors.go +++ b/sdk-go/littlehorse/lh_errors.go @@ -1,9 +1,11 @@ package littlehorse -import "github.com/littlehorse-enterprises/littlehorse/sdk-go/lhproto" - type LHTaskException struct { Name string Message string - Content *lhproto.VariableValue + Content interface{} +} + +func (e *LHTaskException) Error() string { + return e.Message } diff --git a/sdk-go/littlehorse/task_worker_internal.go b/sdk-go/littlehorse/task_worker_internal.go index c2591bf18..743de7edb 100644 --- a/sdk-go/littlehorse/task_worker_internal.go +++ b/sdk-go/littlehorse/task_worker_internal.go @@ -431,11 +431,23 @@ func (m *serverConnectionManager) doTaskHelper(task *lhproto.ScheduledTask) *lhp if errorReflect.Interface() != nil { // Check if the error is an LHTaskException if lhtErr, ok := errorReflect.Interface().(*LHTaskException); ok { + taskErrVarVal, err := InterfaceToVarVal(lhtErr.Content) + + if err != nil { + msg := "Failed to serialize task error content: " + err.Error() + + taskErrVarVal = &lhproto.VariableValue{ + Value: &lhproto.VariableValue_Str{ + Str: msg, + }, + } + } + taskResult.Result = &lhproto.ReportTaskRun_Exception{ Exception: &lhproto.LHTaskException{ Name: lhtErr.Name, Message: lhtErr.Message, - Content: lhtErr.Content, + Content: taskErrVarVal, }, } } else {