Skip to content

Commit a2a4403

Browse files
internal/cmd: print correct config file on parse failure (#749)
Co-authored-by: Kyle Conroy <kyle@conroy.org>
1 parent 7141539 commit a2a4403

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

internal/cmd/generate.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,19 @@ func Generate(e Env, dir string, stderr io.Writer) (map[string]string, error) {
6363
}
6464

6565
if !yamlMissing && !jsonMissing {
66-
fmt.Fprintln(stderr, "error parsing sqlc.json: both files present")
66+
fmt.Fprintln(stderr, "error: both sqlc.json and sqlc.yaml files present")
6767
return nil, errors.New("sqlc.json and sqlc.yaml present")
6868
}
6969

7070
configPath := yamlPath
7171
if yamlMissing {
7272
configPath = jsonPath
7373
}
74+
base := filepath.Base(configPath)
7475

7576
blob, err := ioutil.ReadFile(configPath)
7677
if err != nil {
77-
fmt.Fprintln(stderr, "error parsing sqlc.json: file does not exist")
78+
fmt.Fprintf(stderr, "error parsing %s: file does not exist\n", base)
7879
return nil, err
7980
}
8081

@@ -88,7 +89,7 @@ func Generate(e Env, dir string, stderr io.Writer) (map[string]string, error) {
8889
case config.ErrNoPackages:
8990
fmt.Fprintf(stderr, errMessageNoPackages)
9091
}
91-
fmt.Fprintf(stderr, "error parsing sqlc.json: %s\n", err)
92+
fmt.Fprintf(stderr, "error parsing %s: %s\n", base, err)
9293
return nil, err
9394
}
9495

0 commit comments

Comments
 (0)