yq/pkg/yqlib/operator_error.go
Marco Vito Moscaritolo 6908161f1f replace error creation
2024-11-16 11:48:53 +11:00

21 lines
481 B
Go

package yqlib
import (
"errors"
)
func errorOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
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
}
return Context{}, errors.New(errorMessage)
}