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