mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-14 20:37:55 -05:00
errors: Return error from cast.ToStringE() consistently
This commit is contained in:
parent
2da4ec5738
commit
6f07e5976d
2 changed files with 7 additions and 7 deletions
|
@ -58,7 +58,7 @@ func (ns *Namespace) Translate(ctx context.Context, id any, args ...any) (string
|
|||
|
||||
sid, err := cast.ToStringE(id)
|
||||
if err != nil {
|
||||
return "", nil
|
||||
return "", err
|
||||
}
|
||||
|
||||
return ns.deps.Translate(ctx, sid, templateData), nil
|
||||
|
@ -165,7 +165,7 @@ func (ns *Namespace) FormatNumberCustom(precision, number any, options ...any) (
|
|||
// custom delimiter
|
||||
s, err := cast.ToStringE(options[1])
|
||||
if err != nil {
|
||||
return "", nil
|
||||
return "", err
|
||||
}
|
||||
|
||||
delim = s
|
||||
|
@ -173,7 +173,7 @@ func (ns *Namespace) FormatNumberCustom(precision, number any, options ...any) (
|
|||
|
||||
s, err := cast.ToStringE(options[0])
|
||||
if err != nil {
|
||||
return "", nil
|
||||
return "", err
|
||||
}
|
||||
|
||||
rs := strings.Split(s, delim)
|
||||
|
|
|
@ -42,7 +42,7 @@ type Namespace struct {
|
|||
func (ns *Namespace) AbsURL(s any) (string, error) {
|
||||
ss, err := cast.ToStringE(s)
|
||||
if err != nil {
|
||||
return "", nil
|
||||
return "", err
|
||||
}
|
||||
|
||||
return ns.deps.PathSpec.AbsURL(ss, false), nil
|
||||
|
@ -64,7 +64,7 @@ func (ns *Namespace) Parse(rawurl any) (*url.URL, error) {
|
|||
func (ns *Namespace) RelURL(s any) (string, error) {
|
||||
ss, err := cast.ToStringE(s)
|
||||
if err != nil {
|
||||
return "", nil
|
||||
return "", err
|
||||
}
|
||||
|
||||
return ns.deps.PathSpec.RelURL(ss, false), nil
|
||||
|
@ -74,7 +74,7 @@ func (ns *Namespace) RelURL(s any) (string, error) {
|
|||
func (ns *Namespace) URLize(s any) (string, error) {
|
||||
ss, err := cast.ToStringE(s)
|
||||
if err != nil {
|
||||
return "", nil
|
||||
return "", err
|
||||
}
|
||||
return ns.deps.PathSpec.URLize(ss), nil
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ func (ns *Namespace) URLize(s any) (string, error) {
|
|||
func (ns *Namespace) Anchorize(s any) (string, error) {
|
||||
ss, err := cast.ToStringE(s)
|
||||
if err != nil {
|
||||
return "", nil
|
||||
return "", err
|
||||
}
|
||||
return ns.deps.ContentSpec.SanitizeAnchorName(ss), nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue