Fix error handling during config init (#142)

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.
This commit is contained in:
John Maguire
2021-10-21 14:46:01 -04:00
committed by GitHub
parent 5c5c94b8a9
commit 9ecc62e285
+4 -1
View File
@@ -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
}