Skip to content

Commit

Permalink
Fix error handling during config init (#142)
Browse files Browse the repository at this point in the history
Previously initConfig always returned an error even if it succeeded.
This resulted in a confusing CLI error message that did not match the
executed behavior.

Now it returns an error only if it fails to init the config.
  • Loading branch information
johnmaguire authored Oct 21, 2021
1 parent 5c5c94b commit 9ecc62e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion generate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,8 @@ func initConfig(filename string) error {
return errorf(nil, "unable to write default genqlient.yaml: %v", err)
}
_, err = io.Copy(w, r)
return errorf(nil, "unable to write default genqlient.yaml: %v", err)
if err != nil {
return errorf(nil, "unable to write default genqlient.yaml: %v", err)
}
return nil
}

0 comments on commit 9ecc62e

Please sign in to comment.