X-Git-Url: http://git.giacomolli.uk/onechat/blobdiff_plain/087d725b5ab41ad34ffd24938482d45a8b99a080..d9fddc0f506eb4ead7049f5638674b2b8773fcaa:/terminal.go?ds=inline 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.