Skip to content

Commit

Permalink
Merge branch 'master' into fix/servers-connections-mngt
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlaCarvajal authored Dec 19, 2024
2 parents f616ab4 + 838ac65 commit 1805034
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
8 changes: 5 additions & 3 deletions sdk-go/littlehorse/lh_errors.go
Original file line number Diff line number Diff line change
@@ -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
}
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
14 changes: 13 additions & 1 deletion sdk-go/littlehorse/task_worker_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
taskErrContent, err := InterfaceToVarVal(lhtErr.Content)

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

taskErrContent = &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: taskErrContent,
},
}
} else {
Expand Down

0 comments on commit 1805034

Please sign in to comment.