1
0
mirror of https://github.com/Jguer/yay synced 2024-07-03 08:51:44 +00:00

chore(text): make input overflow its own error

This commit is contained in:
jguer 2021-10-16 09:48:13 +02:00 committed by J Guerreiro
parent 005c5c24b4
commit f925b719e8
2 changed files with 10 additions and 3 deletions

9
pkg/text/errors.go Normal file
View File

@ -0,0 +1,9 @@
package text
import "github.com/leonelquinteros/gotext"
type ErrInputOverflow struct{}
func (e ErrInputOverflow) Error() string {
return gotext.Get("input too long")
}

View File

@ -4,8 +4,6 @@ import (
"bufio"
"fmt"
"os"
"github.com/leonelquinteros/gotext"
)
func GetInput(defaultValue string, noConfirm bool) (string, error) {
@ -24,7 +22,7 @@ func GetInput(defaultValue string, noConfirm bool) (string, error) {
}
if overflow {
return "", fmt.Errorf(gotext.Get("input too long"))
return "", ErrInputOverflow{}
}
return string(buf), nil