From 9ecc62e285ce5e936c943de3f07664f858b64554 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 21 Oct 2021 14:46:01 -0400 Subject: [PATCH] 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. --- generate/config.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/generate/config.go b/generate/config.go index b6a2865..03fa694 100644 --- a/generate/config.go +++ b/generate/config.go @@ -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 }