X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/459656ed8c15847d325f07758e4a775935411c3d..a3b9849a54a6cd8a4cc5b1ae03a39aab31322f7b:/terminal.go diff --git a/terminal.go b/terminal.go index 876986a..eff009c 100644 --- a/terminal.go +++ b/terminal.go @@ -71,7 +71,11 @@ func terminalSession(ctx context.Context, conn net.Conn, in io.Reader, out io.Wr <-shown } - return err + if err != nil { + return fmt.Errorf("run terminal client: %w", err) + } + + return nil } // terminalSendLines sends each line of in as a request until the input ends. @@ -113,7 +117,12 @@ func terminalSendLines(ctx context.Context, conn net.Conn, in io.Reader) error { } } - return scanner.Err() + err := scanner.Err() + if err != nil { + return fmt.Errorf("read terminal input: %w", err) + } + + return nil } // terminalShowEvents writes each event from the daemon to out until the @@ -135,11 +144,16 @@ func terminalShowEvents(conn net.Conn, out io.Writer) error { _, err = io.WriteString(out, text+"\n") if err != nil { - return err + return fmt.Errorf("write terminal event: %w", err) } } - return scanner.Err() + err := scanner.Err() + if err != nil { + return fmt.Errorf("read daemon events: %w", err) + } + + return nil } // terminalCmpError returns err, or fallback when err is nil.