mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-27 18:51:19 +00:00
Prevent confusing template errors when seq is nil
The common is the `where` func and this: ``` panic: reflect: call of reflect.Value.Type on zero Value [recovered] panic: reflect: call of reflect.Value.Type on zero Value ```
This commit is contained in:
parent
2b3b90a6df
commit
8fe1070872
1 changed files with 3 additions and 3 deletions
|
@ -814,7 +814,7 @@ func where(seq, key interface{}, args ...interface{}) (r interface{}, err error)
|
|||
}
|
||||
return rv.Interface(), nil
|
||||
default:
|
||||
return nil, errors.New("can't iterate over " + reflect.ValueOf(seq).Type().String())
|
||||
return nil, fmt.Errorf("can't iterate over %v", seq)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -858,7 +858,7 @@ func apply(seq interface{}, fname string, args ...interface{}) (interface{}, err
|
|||
|
||||
return r, nil
|
||||
default:
|
||||
return nil, errors.New("can't apply over " + reflect.ValueOf(seq).Type().String())
|
||||
return nil, fmt.Errorf("can't apply over %v", seq)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -950,7 +950,7 @@ func delimit(seq, delimiter interface{}, last ...interface{}) (template.HTML, er
|
|||
}
|
||||
|
||||
default:
|
||||
return "", errors.New("can't iterate over " + reflect.ValueOf(seq).Type().String())
|
||||
return "", fmt.Errorf("can't iterate over %v", seq)
|
||||
}
|
||||
|
||||
return template.HTML(str), nil
|
||||
|
|
Loading…
Reference in a new issue