input: return error instead of panicing, fix #2243

Doesn't make much sense panicing here.
This commit is contained in:
Roman Khimov 2021-11-03 19:35:07 +03:00
parent 774dee3cd4
commit 053256f43e

View file

@ -27,7 +27,7 @@ func ReadLine(prompt string) (string, error) {
if trm == nil {
s, err := term.MakeRaw(syscall.Stdin)
if err != nil {
panic(err)
return "", err
}
defer func() { _ = term.Restore(syscall.Stdin, s) }()
trm = term.NewTerminal(ReadWriter{
@ -52,7 +52,7 @@ func ReadPassword(prompt string) (string, error) {
if trm == nil {
s, err := term.MakeRaw(syscall.Stdin)
if err != nil {
panic(err)
return "", err
}
defer func() { _ = term.Restore(syscall.Stdin, s) }()
trm = term.NewTerminal(ReadWriter{os.Stdin, os.Stdout}, prompt)