yq/pkg/yqlib/operator_error.go

21 lines
481 B
Go
Raw Normal View History

package yqlib
import (
2024-11-11 13:06:04 +00:00
"errors"
)
func errorOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
2024-02-15 22:41:33 +00:00
log.Debugf("errorOperation")
rhs, err := d.GetMatchingNodes(context.ReadOnlyClone(), expressionNode.RHS)
if err != nil {
return Context{}, err
}
errorMessage := "aborted"
if rhs.MatchingNodes.Len() > 0 {
errorMessage = rhs.MatchingNodes.Front().Value.(*CandidateNode).Value
}
2024-11-11 13:06:04 +00:00
return Context{}, errors.New(errorMessage)
}