Merge pull request #60919 from dixudx/file_visit_error_info

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

include file name in the error when visiting files

**What this PR does / why we need it**:
/kind bug
/sig cli

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #60916

**Special notes for your reviewer**:
/cc @kubernetes/sig-cli-api-reviews 
**Release note**:

```release-note
include file name in the error when visiting files
```
pull/8/head
Kubernetes Submit Queue 2018-03-20 19:34:23 -07:00 committed by GitHub
commit 3e5596321e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -1,7 +1,7 @@
# Please edit the 'last-applied-configuration' annotations below.
# Lines beginning with a '#' will be ignored, and an empty file will abort the edit.
#
# The edited file had a syntax error: error converting YAML to JSON: yaml: line 12: could not find expected ':'
# The edited file had a syntax error: error parsing edited-file: error converting YAML to JSON: yaml: line 12: could not find expected ':'
#
kind: Service
metadata:

View File

@ -2,7 +2,7 @@
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
# The edited file had a syntax error: error converting YAML to JSON: yaml: line 17: could not find expected ':'
# The edited file had a syntax error: error parsing edited-file: error converting YAML to JSON: yaml: line 17: could not find expected ':'
#
apiVersion: v1
kind: Service

View File

@ -578,7 +578,7 @@ func (v *StreamVisitor) Visit(fn VisitorFunc) error {
if err == io.EOF {
return nil
}
return err
return fmt.Errorf("error parsing %s: %v", v.Source, err)
}
// TODO: This needs to be able to handle object in other encodings and schemas.
ext.Raw = bytes.TrimSpace(ext.Raw)