Merge pull request #15156 from duglin/AddErrTruncIndex
Add missing typed error in truncindex
This commit is contained in:
commit
2b27285a0d
1 changed files with 7 additions and 2 deletions
|
@ -15,8 +15,13 @@ import (
|
||||||
var (
|
var (
|
||||||
// ErrEmptyPrefix is an error returned if the prefix was empty.
|
// ErrEmptyPrefix is an error returned if the prefix was empty.
|
||||||
ErrEmptyPrefix = errors.New("Prefix can't be empty")
|
ErrEmptyPrefix = errors.New("Prefix can't be empty")
|
||||||
// ErrAmbiguousPrefix is an error returned if the prefix was ambiguous (multiple ids for the prefix).
|
|
||||||
|
// ErrAmbiguousPrefix is returned if the prefix was ambiguous
|
||||||
|
// (multiple ids for the prefix).
|
||||||
ErrAmbiguousPrefix = errors.New("Multiple IDs found with provided prefix")
|
ErrAmbiguousPrefix = errors.New("Multiple IDs found with provided prefix")
|
||||||
|
|
||||||
|
// ErrIllegalChar is returned when a space is in the ID
|
||||||
|
ErrIllegalChar = errors.New("illegal character: ' '")
|
||||||
)
|
)
|
||||||
|
|
||||||
// TruncIndex allows the retrieval of string identifiers by any of their unique prefixes.
|
// TruncIndex allows the retrieval of string identifiers by any of their unique prefixes.
|
||||||
|
@ -44,7 +49,7 @@ func NewTruncIndex(ids []string) (idx *TruncIndex) {
|
||||||
|
|
||||||
func (idx *TruncIndex) addID(id string) error {
|
func (idx *TruncIndex) addID(id string) error {
|
||||||
if strings.Contains(id, " ") {
|
if strings.Contains(id, " ") {
|
||||||
return fmt.Errorf("illegal character: ' '")
|
return ErrIllegalChar
|
||||||
}
|
}
|
||||||
if id == "" {
|
if id == "" {
|
||||||
return ErrEmptyPrefix
|
return ErrEmptyPrefix
|
||||||
|
|
Loading…
Reference in a new issue