From ffd1f022aa0ea9c07501e52a47c9bb1b7e10c18f Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Mon, 6 Dec 2021 17:25:32 +1100 Subject: [PATCH] Report while filename failed to parse #1030 --- pkg/yqlib/doc/multiply-merge.md | 2 +- pkg/yqlib/stream_evaluator.go | 3 ++- pkg/yqlib/utils.go | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/yqlib/doc/multiply-merge.md b/pkg/yqlib/doc/multiply-merge.md index 61f1e975..b06a6834 100644 --- a/pkg/yqlib/doc/multiply-merge.md +++ b/pkg/yqlib/doc/multiply-merge.md @@ -244,7 +244,7 @@ Next, we convert the map back to an array, using reduce again, concatenating all Finally, we set the result of the merged array back into the first doc. -To use this, you will need to update '.myArray' to be the expression to your array (e.g. .my.array), and '.a' to be the key field of your array (e.g. '.name') +To use this, you will need to update '.myArray' in the expression to your array (e.g. .my.array), and '.a' to be the key field of your array (e.g. '.name') Thanks Kev from [stackoverflow](https://stackoverflow.com/a/70109529/1168223) diff --git a/pkg/yqlib/stream_evaluator.go b/pkg/yqlib/stream_evaluator.go index b4cf2c6f..f49c6745 100644 --- a/pkg/yqlib/stream_evaluator.go +++ b/pkg/yqlib/stream_evaluator.go @@ -3,6 +3,7 @@ package yqlib import ( "container/list" "errors" + "fmt" "io" "os" @@ -100,7 +101,7 @@ func (s *streamEvaluator) Evaluate(filename string, reader io.Reader, node *Expr s.fileIndex = s.fileIndex + 1 return currentIndex, nil } else if errorReading != nil { - return currentIndex, errorReading + return currentIndex, fmt.Errorf("bad file '%v': %w", filename, errorReading) } candidateNode := &CandidateNode{ diff --git a/pkg/yqlib/utils.go b/pkg/yqlib/utils.go index aa514770..d5d53071 100644 --- a/pkg/yqlib/utils.go +++ b/pkg/yqlib/utils.go @@ -4,6 +4,7 @@ import ( "bufio" "container/list" "errors" + "fmt" "io" "os" "regexp" @@ -122,7 +123,7 @@ func readDocuments(reader io.Reader, filename string, fileIndex int) (*list.List } return inputList, nil } else if errorReading != nil { - return nil, errorReading + return nil, fmt.Errorf("bad file '%v': %w", filename, errorReading) } candidateNode := &CandidateNode{ Document: currentIndex,