]> git.giacomolli.uk - onechat/blobdiff - chatgpt.go
Separate returns from longer statement blocks
[onechat] / chatgpt.go
index 302e143bb732d029378ce5382f9e519eb8753c8f..7a5afc20865b4b547af24fa73449d0ed506e816b 100644 (file)
@@ -145,7 +145,7 @@ func (a *ChatGPTAuth) Login(ctx context.Context, out io.Writer) error {
 
        _, err = fmt.Fprintf(out, "Open %s/codex/device on any device and enter this code:\n\n    %s\n\nWaiting for the approval...\n", a.issuer, userCode)
        if err != nil {
 
        _, err = fmt.Fprintf(out, "Open %s/codex/device on any device and enter this code:\n\n    %s\n\nWaiting for the approval...\n", a.issuer, userCode)
        if err != nil {
-               return err
+               return fmt.Errorf("write device code: %w", err)
        }
 
        grant, err := a.poll(ctx, code.DeviceAuthID, userCode, chatgptPollInterval(code.Interval))
        }
 
        grant, err := a.poll(ctx, code.DeviceAuthID, userCode, chatgptPollInterval(code.Interval))
@@ -164,8 +164,11 @@ func (a *ChatGPTAuth) Login(ctx context.Context, out io.Writer) error {
        }
 
        _, err = fmt.Fprintln(out, "Logged in.")
        }
 
        _, err = fmt.Fprintln(out, "Logged in.")
+       if err != nil {
+               return fmt.Errorf("write login result: %w", err)
+       }
 
 
-       return err
+       return nil
 }
 
 // read reads the token file.
 }
 
 // read reads the token file.