mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
Added better error reporting
This commit is contained in:
parent
a96b74e779
commit
bb088f6aa2
@ -71,7 +71,7 @@ func (p *pathTreeCreator) CreatePathTree(postFixPath []*Operation) (*PathTreeNod
|
|||||||
stack = append(stack, &newNode)
|
stack = append(stack, &newNode)
|
||||||
}
|
}
|
||||||
if len(stack) != 1 {
|
if len(stack) != 1 {
|
||||||
return nil, fmt.Errorf("expected stack to have 1 thing but its %v", stack)
|
return nil, fmt.Errorf("expected end of expression but found '%v', please check expression syntax", strings.TrimSpace(stack[1].Operation.StringValue))
|
||||||
}
|
}
|
||||||
return stack[0], nil
|
return stack[0], nil
|
||||||
}
|
}
|
||||||
|
@ -35,3 +35,8 @@ func TestPathTreeOneArgForOneArgOp(t *testing.T) {
|
|||||||
_, err := treeCreator.ParsePath("explode(.)")
|
_, err := treeCreator.ParsePath("explode(.)")
|
||||||
test.AssertResultComplex(t, nil, err)
|
test.AssertResultComplex(t, nil, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPathTreeExtraArgs(t *testing.T) {
|
||||||
|
_, err := treeCreator.ParsePath("sortKeys(.) explode(.)")
|
||||||
|
test.AssertResultComplex(t, "expected end of expression but found 'explode', please check expression syntax", err.Error())
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user