func terminal(ctx context.Context, in io.Reader, out io.Writer) error {
dir, err := dataDir()
if err != nil {
- return err
+ return fmt.Errorf("find data directory: %w", err)
}
path := filepath.Join(dir, socketFileName)
err = checkSocketPath(path)
if err != nil {
- return err
+ return fmt.Errorf("check terminal socket path: %w", err)
}
var dialer net.Dialer
return fmt.Errorf(`connect to the daemon (start it with "onechat daemon"): %w`, err)
}
- return terminalSession(ctx, conn, in, out)
+ err = terminalSession(ctx, conn, in, out)
+ if err != nil {
+ return fmt.Errorf("run terminal session: %w", err)
+ }
+
+ return nil
}
// terminalSession runs the client on conn until the input ends, the daemon