Skip to content

Commit

Permalink
Allow passed content to be of type LHVariableValue
Browse files Browse the repository at this point in the history
  • Loading branch information
Snarr committed Dec 19, 2024
1 parent 1f13204 commit 7fdd2e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions sdk-go/littlehorse/lh_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ func InterfaceToVarVal(someInterface interface{}) (*lhproto.VariableValue, error
out := &lhproto.VariableValue{}
var err error

interfaceAsVarVal, isVarVal := someInterface.(*lhproto.VariableValue)
if isVarVal {
return interfaceAsVarVal, nil
}

isPtr, _ := GetIsPtrAndType(reflect.TypeOf(someInterface))
if someInterface == nil {
return &lhproto.VariableValue{}, nil
Expand Down
8 changes: 4 additions & 4 deletions sdk-go/littlehorse/task_worker_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,12 @@ 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)
taskErrContent, err := InterfaceToVarVal(lhtErr.Content)

if err != nil {
msg := "Failed to serialize task error content: " + err.Error()
msg := "LH_SDK_GO_ERR: Failed to serialize task error content passed from task worker: " + err.Error()

taskErrVarVal = &lhproto.VariableValue{
taskErrContent = &lhproto.VariableValue{
Value: &lhproto.VariableValue_Str{
Str: msg,
},
Expand All @@ -447,7 +447,7 @@ func (m *serverConnectionManager) doTaskHelper(task *lhproto.ScheduledTask) *lhp
Exception: &lhproto.LHTaskException{
Name: lhtErr.Name,
Message: lhtErr.Message,
Content: taskErrVarVal,
Content: taskErrContent,
},
}
} else {
Expand Down

0 comments on commit 7fdd2e7

Please sign in to comment.