X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/d28e3b2858db322899a81b59a30400c1acad2b42..e86df5fad9aa2f280aad845adeefd239b0e944ae:/terminal.go diff --git a/terminal.go b/terminal.go index da0d78a..340a8aa 100644 --- a/terminal.go +++ b/terminal.go @@ -30,13 +30,13 @@ var errTerminalDaemonClosed = errors.New("the daemon closed the connection") 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 @@ -46,7 +46,12 @@ func terminal(ctx context.Context, in io.Reader, out io.Writer) error { 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