diff options
author | seiya <[email protected]> | 2024-04-03 09:12:13 +0900 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-04-04 11:00:14 +0200 |
commit | 6f07e5976de426c9637e77e3ae912df342c2b782 (patch) | |
tree | 7111f5792feefa15a6975b6900f9184f1f90c98d | |
parent | 2da4ec5738e9b9060aab37247312244e1b8a318d (diff) | |
download | hugo-6f07e5976de426c9637e77e3ae912df342c2b782.tar.gz hugo-6f07e5976de426c9637e77e3ae912df342c2b782.zip |
errors: Return error from cast.ToStringE() consistently
-rw-r--r-- | tpl/lang/lang.go | 6 | ||||
-rw-r--r-- | tpl/urls/urls.go | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/tpl/lang/lang.go b/tpl/lang/lang.go index 92b3aa8ff..b4ff98684 100644 --- a/tpl/lang/lang.go +++ b/tpl/lang/lang.go @@ -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) diff --git a/tpl/urls/urls.go b/tpl/urls/urls.go index 6c4681a0c..b7bfa22b9 100644 --- a/tpl/urls/urls.go +++ b/tpl/urls/urls.go @@ -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 } |