Skip to content

Commit

Permalink
Add clearer error text a few places (#117)
Browse files Browse the repository at this point in the history
## Summary:
It's nice to be clear here because it may be your first interaction with
genqlient!

## Test plan:
make check


Author: benjaminjkraft

Reviewers: StevenACoffman, benjaminjkraft, dnerdy

Required Reviewers: 

Approved By: StevenACoffman

Checks: ✅ Test (1.17), ✅ Test (1.16), ✅ Test (1.15), ✅ Test (1.14), ✅ Lint, ✅ Test (1.17), ✅ Test (1.16), ✅ Test (1.15), ✅ Test (1.14), ✅ Lint

Pull Request URL: #117
  • Loading branch information
benjaminjkraft authored Sep 28, 2021
1 parent 65c3e20 commit b84dda2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions generate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ func initConfig(filename string) error {
}
w, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o644)
if err != nil {
return err
return errorf(nil, "unable to write default genqlient.yaml: %v", err)
}
_, err = io.Copy(w, r)
return err
return errorf(nil, "unable to write default genqlient.yaml: %v", err)
}
3 changes: 2 additions & 1 deletion generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ func Generate(config *Config) (map[string][]byte, error) {
// way. (As-is, we generate a broken file, with just (unused) imports.)
if len(document.Operations) == 0 {
// Hard to have a position when there are no operations :(
return nil, errorf(nil, "no queries found, looked in: %v",
return nil, errorf(nil,
"no queries found, looked in: %v (configure this in genqlient.yaml)",
strings.Join(config.Operations, ", "))
}

Expand Down
2 changes: 1 addition & 1 deletion generate/testdata/snapshots/TestGenerateErrors-NoQuery-go
Original file line number Diff line number Diff line change
@@ -1 +1 @@
no queries found, looked in: testdata/errors/NoQuery.go
no queries found, looked in: testdata/errors/NoQuery.go (configure this in genqlient.yaml)
Original file line number Diff line number Diff line change
@@ -1 +1 @@
no queries found, looked in: testdata/errors/NoQuery.graphql
no queries found, looked in: testdata/errors/NoQuery.graphql (configure this in genqlient.yaml)

0 comments on commit b84dda2

Please sign in to comment.