Skip to content

Commit

Permalink
tpl: Modified error messages of after, first, and last
Browse files Browse the repository at this point in the history
Modified the messages functions after, first, and last threw on being passed invalid parameters (index or limit) to be more standardised and resemble what Go compiler would throw.

Fixes gohugoio#6415
  • Loading branch information
BaibhaVatsa committed Oct 11, 2019
1 parent 0e75af7 commit 4d93201
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tpl/collections/collections.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (ns *Namespace) After(index interface{}, seq interface{}) (interface{}, err
}

if indexv < 0 {
return nil, errors.New("can't return negative/empty count of items from sequence")
return nil, errors.New("sequence bounds out of range [" + cast.ToString(indexv) + ":]")
}

seqv := reflect.ValueOf(seq)
Expand Down Expand Up @@ -219,7 +219,7 @@ func (ns *Namespace) First(limit interface{}, seq interface{}) (interface{}, err
}

if limitv < 0 {
return nil, errors.New("can't return negative count of items from sequence")
return nil, errors.New("sequence length must be non-negative")
}

seqv := reflect.ValueOf(seq)
Expand Down Expand Up @@ -379,7 +379,7 @@ func (ns *Namespace) Last(limit interface{}, seq interface{}) (interface{}, erro
}

if limitv < 0 {
return nil, errors.New("can't return negative/empty count of items from sequence")
return nil, errors.New("sequence length must be non-negative")
}

seqv := reflect.ValueOf(seq)
Expand Down

0 comments on commit 4d93201

Please sign in to comment.